fix: keep link addresses in the plain text version of emails

MR
16h ago
+41-3

Closes #34216

Proposed changes

The text/plain part of an email is generated from its html with stripHtml, which drops every href. In offline message alerts the text part read admin sent you a message GO TO MESSAGE with no address, so recipients using "Send only plain text emails" or a plain text client had no way to open the message.

  • New htmlToPlainText (server/lib/notifications/email/): the same stripHtml conversion, with dumpLinkHrefsNearby enabled so each link's address follows its label, e.g. GO TO MESSAGE (https://…/direct/abc?msg=xyz). This uses the same options that EmailInbox_Incoming already passes for incoming emails.
  • The mailer uses it in both places where it derives text from html (send and sendNoWrap). Emails that pass an explicit text are unchanged.

Steps to test or reproduce

  1. Enable "Send only plain text emails" (or read the text/plain part).
  2. Receive an offline message alert.
  3. Before: GO TO MESSAGE with no link. After: GO TO MESSAGE (<message url>).

Tests

htmlToPlainText.test.ts: the link case fails on develop with expected 'admin sent you a message GO TO MESSAGE' to include 'GO TO MESSAGE (https://…)' and passes with this change. The existing mailer and getEmailContent tests still pass.

Summary by CodeRabbit

  • Bug Fixes
    • Plain-text emails now include link addresses alongside their labels, including the “Go to message” link in offline message alerts.