Allow configuring a dedicated OCR user - #388
Open
R0Wi wants to merge 1 commit into
Open
Conversation
Automated OCR operations were always attributed to the owner of the processed file, because the app impersonates that user to get proper filesystem permissions. This makes automated OCR indistinguishable from a manual user edit in the file version history and the activity log. Add an optional global setting "OCR user". If it is set, the whole OCR processing (user session, filesystem and therefore the resulting file version) runs with that account instead of the file owner. If it is not set, nothing changes and the file owner is impersonated as before. Notifications are still sent to the file owner, and if the configured user does not exist the app logs a warning and falls back to the owner. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PjP5Wsw6uiKSBPiXp9N7sf
There was a problem hiding this comment.
Pull request overview
Adds an optional global “OCR user” setting so automated OCR runs (filesystem session, version author/activity attribution) can be executed as a dedicated service account instead of impersonating the file owner, addressing audit-trail/accountability concerns from #385 while keeping notifications targeted to the file owner.
Changes:
- Introduces a new nullable global setting (
processingUserId) and normalizes blank input tonullacross controller/service/UI. - Updates OCR execution to choose a “processing user” (configured user or fallback to owner) while keeping the “owner user” for notifications.
- Adds/updates PHPUnit + Vue unit tests covering configured-user behavior and fallback when the configured user does not exist.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| lib/Model/GlobalSettings.php | Adds nullable processingUserId global setting. |
| lib/Service/GlobalSettingsService.php | Maps empty-string string settings to null when the property is nullable. |
| lib/Controller/GlobalSettingsController.php | Trims/normalizes processingUserId input to null when blank. |
| lib/Service/OcrService.php | Determines processing UID from global setting and separates processing user vs owner for notifications. |
| src/components/GlobalSettings.vue | Adds admin UI input for “OCR user” and saves normalized values. |
| src/test/components/GlobalSettings.spec.js | Adds Vue tests for trimming and nulling the new setting. |
| tests/Unit/Service/GlobalSettingsServiceTest.php | Updates unit tests for new nullable string setting + empty-string handling. |
| tests/Unit/Controller/GlobalSettingsControllerTest.php | Adds controller tests for trimming and mapping blank inputs to null. |
| tests/Unit/Service/OcrServiceTest.php | Adds tests for running as configured processing user and fallback when missing. |
| README.md | Documents the new “OCR user” setting and required permissions/fallback behavior. |
Suppressed comments (1)
lib/Service/OcrService.php:261
- The PHPDoc line has an extra leading "" (" * @PARAM"), which makes the docblock malformed and can confuse tooling/IDEs.
/**
* * @param string $uid The userId to run the OCR process with
*/
| * the owner of the file to be processed. If an admin configured a dedicated | ||
| * processing user globally, this user is used instead (#385). | ||
| * | ||
| * @param string $uid The owners userId of the file to be processed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Changes
lib/Model/GlobalSettings.php: new nullableprocessingUserIdsetting.lib/Service/OcrService.php: reads global settings before initializing the user environment, determines the processing uid (configured user, or file owner as fallback), and separates the "processing user" from the "owner" (used for notifications).lib/Service/GlobalSettingsService.php: empty string now maps tonullfor nullable string settings, mirroring the existing0 -> nullbehavior for ints.lib/Controller/GlobalSettingsController.php: trims and normalizes blank input tonull.src/components/GlobalSettings.vue: new text input for the OCR user, saved on blur.README.md: documents the new setting and its permission requirements.Test plan
OcrServiceTest::testRunsOcrProcessWithConfiguredProcessingUserandtestFallsBackToFileOwnerIfConfiguredProcessingUserDoesNotExist.GlobalSettingsServiceTestandGlobalSettingsControllerTestfor the new setting (including null/blank handling).GlobalSettings.spec.js.Imagickextension, running as root).npm run test:unit(53 passed),npm run lint, andcomposer cs:check— all clean, no new issues introduced.Generated by Claude Code