Skip to content

Migrate remaining mailers to format_mail_html / format_mail_text - #23387

Merged
akabiru merged 1 commit into
devfrom
refactor/migrate-remaining-mailers-to-render-mode
May 28, 2026
Merged

Migrate remaining mailers to format_mail_html / format_mail_text#23387
akabiru merged 1 commit into
devfrom
refactor/migrate-remaining-mailers-to-render-mode

Conversation

@akabiru

@akabiru akabiru commented May 27, 2026

Copy link
Copy Markdown
Member

Ticket

https://community.openproject.org/wp/75389

Follow-up to #23337. Stacked on that PR — the diff will collapse once #23337 lands in dev.

Note

Related: opf/rubocop-openproject#5 introduces OpenProject/UseRenderModeInsteadOfPrimitives, which flags the pre-migration shape (static_html: true / plain_text: true / only_path: false on format_text).

What are you trying to accomplish?

Mailer views still carry the static_html: true / only_path: false / plain_text: true boilerplate on every format_text call. This PR routes the remaining sites through format_mail_html / format_mail_text so render_mode: is pinned once at the helper layer.

Migrated surfaces:

  • UserMailermessage_posted, news_added, news_comment_added
  • ProjectMailerproject_created
  • ProjectArtifactsMailercreation_wizard_submitted
  • MemberMaileradded_project, updated_project, updated_global
  • AnnouncementMailerannounce (body, header, subheader)
  • DocumentsMailerdocument_added
  • Shared layoutlocalized_emails_header, localized_emails_footer (previously called OpenProject::TextFormatting::Renderer.format_text directly, bypassing the helper)

Merge checklist

  • Added/updated tests
  • Added/updated documentation in Lookbook (patterns, previews, etc)
  • Tested major browsers (Chrome, Firefox, Edge, ...)

@oliverguenther oliverguenther left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the extra mile @akabiru 👍

The view-helper migration introduced by the parent PR now covers the
remaining mailer surfaces: UserMailer (`message_posted`, `news_added`,
`news_comment_added`), ProjectMailer (`project_created`),
ProjectArtifactsMailer (`creation_wizard_submitted`), MemberMailer
(`added_project`, `updated_project`, `updated_global`), AnnouncementMailer
(`announce`), DocumentsMailer (`document_added`), and the shared mailer
layout (`localized_emails_header`, `localized_emails_footer`).

Sites drop the `static_html: true` / `only_path: false` / `plain_text: true`
boilerplate; `render_mode:` pinning lives in the helper.

The layout previously called `OpenProject::TextFormatting::Renderer.format_text`
directly, bypassing the helper layer. The empty visibility cache (no
current_user-scoped preload at layout time) is handled by the existing
fallback in `LinkHandlers::WorkPackages#text_only?` — covered by a new
sanity spec in `user_mailer_spec.rb` that exercises the header path with
a WP reference and asserts plain-text formatted_id rendering.

Per-bucket regression coverage added: absolute-URL and formatted_id
assertions across both classic and semantic identifier modes, mirroring
the WorkPackageMailer spec pattern.
@akabiru
akabiru force-pushed the refactor/migrate-remaining-mailers-to-render-mode branch from 89e2d01 to ec2a025 Compare May 28, 2026 09:07
@akabiru
akabiru marked this pull request as ready for review May 28, 2026 09:07
@github-actions

Copy link
Copy Markdown

Caution

The provided work package version does not match the core version

Details:

Please make sure that:

  • The work package version OR your pull request target branch is correct

@akabiru
akabiru merged commit f12fc75 into dev May 28, 2026
16 of 17 checks passed
@akabiru
akabiru deleted the refactor/migrate-remaining-mailers-to-render-mode branch May 28, 2026 09:48
@github-actions github-actions Bot locked and limited conversation to collaborators May 28, 2026
@akabiru akabiru added this to the 17.6.x milestone May 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Development

Successfully merging this pull request may close these issues.

2 participants