Skip to content

refactor: extract email batch-time logic into UserSettings::getEmailBatchTimeSetting()#2570

Open
miaulalala wants to merge 1 commit intomasterfrom
refactor/email-batchtime-helper
Open

refactor: extract email batch-time logic into UserSettings::getEmailBatchTimeSetting()#2570
miaulalala wants to merge 1 commit intomasterfrom
refactor/email-batchtime-helper

Conversation

@miaulalala
Copy link
Copy Markdown
Collaborator

Summary

The pattern:

$this->userSettings->getUserSetting($user, 'email', $type)
    ? $this->userSettings->getUserSetting($user, 'setting', 'batchtime')
    : false

was duplicated 7 times in FilesHooks and once in Consumer. It encodes a single piece of domain logic: "return the batch-time delay if email is enabled for this user and type, otherwise false."

Extracted to UserSettings::getEmailBatchTimeSetting(string $user, string $type): int|false and replaced all 8 call sites. Updated the 5 affected FilesHooksTest mock setups accordingly.

Test plan

  • 2 new UserSettingsTest cases (email disabled → false, email enabled → batchtime) — green
  • UserSettingsTest full suite — green
  • FilesHooksTest full suite — green
  • ConsumerTest full suite — green

🤖 Generated with Claude Code

…atchTimeSetting()

The pattern `getUserSetting($user, 'email', $type) ? getUserSetting($user,
'setting', 'batchtime') : false` was duplicated 7 times in FilesHooks and
once in Consumer. Extract it to a named method on UserSettings and replace
all call sites. Adds two unit tests covering the enabled and disabled paths.

Signed-off-by: Anna Larch <anna@nextcloud.com>
AI-Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@cypress
Copy link
Copy Markdown

cypress Bot commented May 6, 2026

Activity    Run #3708

Run Properties:  status check passed Passed #3708  •  git commit b6654e8f7a: refactor: extract email batch-time logic into UserSettings::getEmailBatchTimeSet...
Project Activity
Branch Review refactor/email-batchtime-helper
Run status status check passed Passed #3708
Run duration 02m 05s
Commit git commit b6654e8f7a: refactor: extract email batch-time logic into UserSettings::getEmailBatchTimeSet...
Committer Anna
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 1
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 9
View all changes introduced in this branch ↗︎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant