Skip to content

fix(bulkReceive): honour admin email toggle and ISetting notification defaults#2562

Open
miaulalala wants to merge 2 commits intomasterfrom
fix/bulk-receive-email-notification-bypass
Open

fix(bulkReceive): honour admin email toggle and ISetting notification defaults#2562
miaulalala wants to merge 2 commits intomasterfrom
fix/bulk-receive-email-notification-bypass

Conversation

@miaulalala
Copy link
Copy Markdown
Collaborator

@miaulalala miaulalala commented May 6, 2026

Summary

  • Email bug (main issue, stable33+master): bulkReceive() was querying per-user email settings via IUserConfig::getValuesByUsers() — a raw DB query with no knowledge of the admin enable_email toggle. This caused activity emails to be sent to all users even when an admin had globally disabled them. Added the same enable_email guard that already exists in UserSettings::getUserSetting() and filterUsersBySetting().

  • Notification bug: When canChangeNotification() is false, $userPushSettings was left null, making $notificationSetting resolve to null. The guard null !== false is always true, so push notifications fired unconditionally. Fixed by deriving $defaultPushEnabled from ISetting::isDefaultEnabledNotification() and using it as the authoritative value when the user cannot change the setting.

Test plan

  • composer test:unit passes (326 tests, 1580 assertions)
  • New test testBulkReceiveNoMailWhenAdminEmailDisabled verifies that getValuesByUsers is never called and no mail is queued when enable_email=no
  • Updated tests confirm corrected notification behaviour for non-user-configurable activity types
  • Backport to stable33 via GitHub

🤖 Generated with Claude Code

miaulalala added 2 commits May 6, 2026 12:53
… defaults

bulkReceive() bypassed UserSettings::getUserSetting() in favour of raw
IUserConfig::getValuesByUsers() calls, losing two guards that exist in the
single-user receive() path:

1. The admin enable_email toggle was never checked, so activity emails were
   queued for all users even when an admin had globally disabled them.

2. When canChangeNotification() is false the per-user push settings map was
   never populated, leaving $notificationSetting as null. Because
   null !== false evaluates to true, push notifications fired unconditionally
   for every affected user regardless of ISetting::isDefaultEnabledNotification().

Fix: add the enable_email guard before querying per-user email prefs, and
derive a $defaultPushEnabled from ISetting so the fallback mirrors what
getUserSetting() returns when canModifySetting() is false.

AI-Assisted-By: claude-sonnet-4-6
Signed-off-by: Anna Larch <anna@nextcloud.com>
…ation fixes

- Inject IConfig mock into Consumer constructor (6th arg added by fix)
- Update testBulkReceiveNoMailWhenSettingDisabled: notification must not fire
  when isDefaultEnabledNotification() returns false (old test encoded the
  null !== false bug)
- Update testBulkReceiveMultipleUsersWithMixedSettings: only users with an
  explicit true DB entry get a notification; absent entries now fall back to
  isDefaultEnabledNotification() instead of always sending
- Update testBulkReceiveWithISetting: ISetting (non-ActivitySettings) now
  yields defaultPushEnabled=false, so no notification is sent
- Add testBulkReceiveNoMailWhenAdminEmailDisabled: verifies that when the
  admin sets enable_email=no, getValuesByUsers is never called and no mail
  is queued even if the activity type has mail enabled by default

AI-Assisted-By: claude-sonnet-4-6
Signed-off-by: Anna Larch <anna@nextcloud.com>
@miaulalala miaulalala force-pushed the fix/bulk-receive-email-notification-bypass branch from 4b21461 to eb8f9a4 Compare May 6, 2026 10:53
@cypress
Copy link
Copy Markdown

cypress Bot commented May 6, 2026

Activity    Run #3692

Run Properties:  status check passed Passed #3692  •  git commit 20c791a13e: fix(bulkReceive): honour admin email toggle and ISetting notification defaults
Project Activity
Branch Review fix/bulk-receive-email-notification-bypass
Run status status check passed Passed #3692
Run duration 01m 58s
Commit git commit 20c791a13e: fix(bulkReceive): honour admin email toggle and ISetting notification defaults
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 ↗︎

@miaulalala
Copy link
Copy Markdown
Collaborator Author

/backport to stable33

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