Skip to content

fix(MailQueueHandler): check enable_email toggle before sending queued emails#2563

Open
miaulalala wants to merge 2 commits intomasterfrom
fix/mail-queue-handler-email-toggle
Open

fix(MailQueueHandler): check enable_email toggle before sending queued emails#2563
miaulalala wants to merge 2 commits intomasterfrom
fix/mail-queue-handler-email-toggle

Conversation

@miaulalala
Copy link
Copy Markdown
Collaborator

@miaulalala miaulalala commented May 6, 2026

Summary

The admin Enable notification emails toggle was only checked when queuing new emails (Consumer::receive() / bulkReceive()). The MailQueueHandler::sendEmails() background job that actually delivers emails had no knowledge of the toggle and would send all queued entries regardless.

This means: if emails were already sitting in oc_activity_mq when an admin disabled the toggle, they would still be sent on the next background job run.

The fix adds an early-return guard at the top of sendEmails(), consistent with the checks already in UserSettings::getUserSetting() and filterUsersBySetting(). The queue is intentionally left intact — if the admin re-enables emails, pending notifications can still be delivered.

Related to #2562 (which fixed the same missing check in bulkReceive()).

Test plan

  • composer test:unit passes (327 tests)
  • New test testSendEmailsSkipsWhenAdminEmailDisabled verifies: return value is 0, mailer is never called, queue entries survive
  • Backport to stable33

🤖 Generated with Claude Code

miaulalala added 2 commits May 6, 2026 23:13
…d emails

sendEmails() was a raw consumer of the activity_mq queue with no knowledge
of the admin enable_email toggle. Emails queued before the toggle was
disabled would still be sent by the background job on its next run, because
only the queuing paths (Consumer::receive and bulkReceive) checked the
setting — the send path did not.

Add an early-return guard at the top of sendEmails() that mirrors the check
already present in UserSettings::getUserSetting() and filterUsersBySetting().
The queue is intentionally left intact so that if the admin re-enables
emails, any pending notifications can still be delivered.

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

Add testSendEmailsSkipsWhenAdminEmailDisabled: when enable_email=no, sendEmails
must return 0, never call mailer->send(), and leave all queue entries intact.

Signed-off-by: Anna Larch <anna@nextcloud.com>
AI-Assisted-By: claude-sonnet-4-6
@miaulalala
Copy link
Copy Markdown
Collaborator Author

/backport to stable33

@cypress
Copy link
Copy Markdown

cypress Bot commented May 6, 2026

Activity    Run #3698

Run Properties:  status check passed Passed #3698  •  git commit a39a47bd22: fix(MailQueueHandler): check enable_email toggle before sending queued emails
Project Activity
Branch Review fix/mail-queue-handler-email-toggle
Run status status check passed Passed #3698
Run duration 01m 59s
Commit git commit a39a47bd22: fix(MailQueueHandler): check enable_email toggle before sending queued emails
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 stable32

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