discourse/spec
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
..
fabricators UX: Use dominant color as image loading placeholder (#18248) 2022-09-20 10:28:17 +01:00
fixtures FEATURE: Add support for case-sensitive Watched Words (#17445) 2022-08-02 10:06:03 +02:00
helpers DEV: output sitelinks search tag on homepage only (#16157) 2022-09-23 15:05:53 +08:00
import_export DEV: Use proper wording for contexts in specs 2022-08-04 11:05:02 +02:00
initializers Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
integration DEV: Use AR enums in reviewables related code 2022-09-22 14:44:27 +02:00
integrity DEV: Use proper wording for contexts in specs 2022-08-04 11:05:02 +02:00
jobs FEATURE: Overhaul email threading (#17996) 2022-09-26 09:14:24 +10:00
lib FEATURE: Overhaul email threading (#17996) 2022-09-26 09:14:24 +10:00
mailers DEV: Use proper wording for contexts in specs 2022-08-04 11:05:02 +02:00
models FIX: Handle failed download when calculating image dominant color (#18342) 2022-09-23 12:42:07 +01:00
multisite DEV: Use proper wording for contexts in specs 2022-08-04 11:05:02 +02:00
requests UX: Use dominant color as image loading placeholder (#18248) 2022-09-20 10:28:17 +01:00
script/import_scripts DEV: Use proper wording for contexts in specs 2022-08-04 11:05:02 +02: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
support DEV: Use proper wording for contexts in specs 2022-08-04 11:05:02 +02:00
tasks FEATURE: Create upload_references table (#16146) 2022-06-09 09:24:30 +10:00
views Add RSpec 4 compatibility (#17652) 2022-07-28 10:27:38 +08:00
rails_helper.rb DEV: Apply Rails 6.1 defaults 2022-05-24 17:13:44 +02:00
regenerate_swagger_docs DEV: Add API docs for uploads and API doc watcher (#15387) 2021-12-23 08:40:15 +10:00
swagger_helper.rb DEV: Fix openapi definition logo URL (#17038) 2022-06-08 13:10:20 +01:00