Skip to content

Allow configuring a dedicated OCR user - #388

Open
R0Wi wants to merge 1 commit into
masterfrom
claude/workflow-ocr-user-setting-5tbsw5
Open

Allow configuring a dedicated OCR user#388
R0Wi wants to merge 1 commit into
masterfrom
claude/workflow-ocr-user-setting-5tbsw5

Conversation

@R0Wi

@R0Wi R0Wi commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fixes Automated OCR operations are attributed to the impersonated file owner (audit-trail / accountability concern) #385: automated OCR operations were always attributed to the impersonated file owner, making them indistinguishable from manual edits in the version history and activity log.
  • Adds an optional global admin setting ("OCR user"). If left empty (default), behavior is unchanged and the file owner is impersonated as before. If set, the whole OCR run (user session, filesystem access, resulting file version/label) runs as that configured user instead.
  • Success notifications are still always sent to the file owner. If the configured user doesn't exist, the app logs a warning and falls back to the file owner.

Changes

  • lib/Model/GlobalSettings.php: new nullable processingUserId setting.
  • 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 to null for nullable string settings, mirroring the existing 0 -> null behavior for ints.
  • lib/Controller/GlobalSettingsController.php: trims and normalizes blank input to null.
  • 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

  • Added OcrServiceTest::testRunsOcrProcessWithConfiguredProcessingUser and testFallsBackToFileOwnerIfConfiguredProcessingUserDoesNotExist.
  • Updated GlobalSettingsServiceTest and GlobalSettingsControllerTest for the new setting (including null/blank handling).
  • Added Vue tests for the new input in GlobalSettings.spec.js.
  • Ran full PHPUnit suite against a real Nextcloud (master) checkout — all workflow_ocr tests pass except 4 pre-existing/environmental failures unrelated to this change (missing Imagick extension, running as root).
  • Ran npm run test:unit (53 passed), npm run lint, and composer cs:check — all clean, no new issues introduced.

Generated by Claude Code

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 to null across 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automated OCR operations are attributed to the impersonated file owner (audit-trail / accountability concern)

3 participants