Repository navigation
Ensure we always render mails in the context of the recipient - #27357
Merged
Merged
Conversation
ApplicationMailer#mail now runs inside User.execute_as(recipient). All fomatted texts and references will be resolved using the recipient user. Previously, the mailers were not consistent in selecting a user to execute with. Only MemberMailer, WorkPackageMailer and the meeting mailers already switched the user. News, comments, forum messages, documents, announcements, project creation mails and the configurable mail header/footer rendered as whoever was current, which is the anonymous user in background jobs and the author when delivered inline. Some of these mailers still do their own switch in a block, as that code runs BEFORE the mail method is called. https://community.openproject.org/work_packages/SC-355
Contributor
|
Shall we also remove the other switches and leave the tests in place, that they still do the right thing? |
MemberMailer and WorkPackageMailer switched to the recipient only to render the mail body. ApplicationMailer#mail now does this for every mail. The meeting mailers need the wrapper because they build the ICS in the recipient's locale before mail gets called.
Member
Author
We can do that for some of the calls, not for all (as some are called before |
klaustopher
previously approved these changes
Nov 26, 2026
Backporting the fix resulted in broken specs. The release branch has no UserMailer#message_mentioned and spells the wizard mailer ProjectArtifactsMailer
klaustopher
approved these changes
Nov 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ticket
https://community.openproject.org/work_packages/SC-355
What are you trying to accomplish?
ApplicationMailer#mail now runs inside User.execute_as(recipient). All fomatted texts and references will be resolved using the recipient user.
Previously, the mailers were not consistent in selecting a user to execute with. Only MemberMailer, WorkPackageMailer and the meeting mailers already switched the user.
News, comments, forum messages, documents, announcements, project creation mails and the configurable mail header/footer rendered as whoever was current, which is the anonymous user in background jobs and the author when delivered inline.
Some of these mailers still do their own switch in a block, as that code runs BEFORE the mail method is called.
AI involvement
Collaborative – AI generated a substantial part of the code; I reviewed and understand every line.
Merge checklist