Skip to content

fix(mail): always reset current user after sending activity emails - #2814

Merged
miaulalala merged 1 commit into
masterfrom
fix/reset-current-user-after-sending-mails
Jul 22, 2026
Merged

fix(mail): always reset current user after sending activity emails#2814
miaulalala merged 1 commit into
masterfrom
fix/reset-current-user-after-sending-mails

Conversation

@karlitschek

Copy link
Copy Markdown
Member

MailQueueHandler::sendEmailToUser() and DigestSender::sendDigestForUser() set the current user on the activity manager but only reset it on the success path. Early returns (no activities for the digest) and failures (mailer errors, exceptions while building the mail — which the digest loop catches and continues) left the activity manager impersonating that user for the remaining users of the same cron run, leaking activity visibility between users.

Wrap the impersonated sections in try/finally so the current user is always reset.

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

MailQueueHandler::sendEmailToUser() and DigestSender::sendDigestForUser()
set the current user on the activity manager but only reset it on the
success path. Early returns (no activities for the digest) and failures
(mailer errors, exceptions while building the mail — which the digest
loop catches and continues) left the activity manager impersonating
that user for the remaining users of the same cron run, leaking
activity visibility between users.

Wrap the impersonated sections in try/finally so the current user is
always reset.

Signed-off-by: Frank Karlitschek <karlitschek@users.noreply.github.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@karlitschek

Copy link
Copy Markdown
Member Author

@nickvergessen

@miaulalala
miaulalala merged commit ec56679 into master Jul 22, 2026
51 checks passed
@miaulalala
miaulalala deleted the fix/reset-current-user-after-sending-mails branch July 22, 2026 18:36
@AndyScherzinger AndyScherzinger added this to the Nextcloud 35 milestone Aug 9, 2026
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.

3 participants