discourse/app
Martin Brennan e3d495850d
FEATURE: Overhaul email threading (#17996)
See https://meta.discourse.org/t/discourse-email-messages-are-incorrectly-threaded/233499
for thorough reasoning.

This commit changes how we generate Message-IDs and do email
threading for emails sent from Discourse. The main changes are
as follows:

* Introduce an outbound_message_id column on Post that
  is either a) filled with a Discourse-generated Message-ID
  the first time that post is used for an outbound email
  or b) filled with an original Message-ID from an external
  mail client or service if the post was created from an
  incoming email.
* Change Discourse-generated Message-IDs to be more consistent
  and static, in the format `discourse/post/:post_id@:host`
* Do not send References or In-Reply-To headers for emails sent
  for the OP of topics.
* Make sure that In-Reply-To is filled with either a) the OP's
  Message-ID if the post is not a direct reply or b) the parent
  post's Message-ID
* Make sure that In-Reply-To has all referenced post's Message-IDs
* Make sure that References is filled with a chain of Message-IDs
  from the OP down to the parent post of the new post.

We also are keeping X-Discourse-Post-Id and X-Discourse-Topic-Id,
headers that we previously removed, for easier visual debugging
of outbound emails.

Finally, we backfill the `outbound_message_id` for posts that have
a linked `IncomingEmail` record, using the `message_id` of that record.
We do not need to do that for posts that don't have an incoming email
since they are backfilled at runtime if `outbound_message_id` is missing.
2022-09-26 09:14:24 +10:00
..
assets UX: Fix cut-off accents in sidebar headings (#18349) 2022-09-23 17:18:58 -07:00
controllers DEV: Use AR enums in reviewables related code 2022-09-22 14:44:27 +02:00
helpers DEV: output sitelinks search tag on homepage only (#16157) 2022-09-23 15:05:53 +08:00
jobs DEV: Use AR enums in reviewables related code 2022-09-22 14:44:27 +02:00
mailers FEATURE: Custom unsubscribe options (#17090) 2022-06-21 15:49:47 -03:00
models FEATURE: Overhaul email threading (#17996) 2022-09-26 09:14:24 +10:00
serializers DEV: Use AR enums in reviewables related code 2022-09-22 14:44:27 +02:00
services DEV: Use AR enums in reviewables related code 2022-09-22 14:44:27 +02:00
views DEV: Remove support for legacy plugin JS compilation pipeline (#18293) 2022-09-21 12:38:02 +01:00