FIX: Improve tags in email subjects and add filter headers (#19760)

This commit does a couple of things:

1. Changes the limit of tags to include a subject for a
   notification email to the `max_tags_per_topic` setting
   instead of the arbitrary 3 limit
2. Adds both an X-Discourse-Tags and X-Discourse-Category
   custom header to outbound emails containing the tags
   and category from the subject, so people on mail clients
   that allow advanced filtering (i.e. not Gmail) can filter
   mail by tags and category, which is useful for mailing
   list mode users

c.f. https://meta.discourse.org/t/headers-for-email-notifications-so-that-gmail-users-can-filter-on-tags/249982/17
This commit is contained in:
Martin Brennan
2023-01-06 10:03:02 +10:00
committed by GitHub
parent 12f843068d
commit c4ea158656
4 changed files with 29 additions and 1 deletions

View File

@ -161,6 +161,11 @@ module Email
result['X-Discourse-Post-Id'] = @opts[:post_id].to_s if @opts[:post_id]
result['X-Discourse-Topic-Id'] = @opts[:topic_id].to_s if @opts[:topic_id]
# at this point these have been filtered by the recipient's guardian for visibility,
# see UserNotifications#send_notification_email
result['X-Discourse-Tags'] = @template_args[:show_tags_in_subject] if @opts[:show_tags_in_subject]
result['X-Discourse-Category'] = @template_args[:show_category_in_subject] if @opts[:show_category_in_subject]
# please, don't send us automatic responses...
result['X-Auto-Response-Suppress'] = 'All'