mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 07:56:02 +08:00
FIX: Canonical Message-ID was incorrect for some cases (#15701)
When creating a direct message to a group with group SMTP set up, and adding another person to that message in the OP, we send an email to the second person in the OP via the group_smtp job. This in turn creates an IncomingEmail record to guard against IMAP double sync. The issue with this was that this IncomingEmail (which is essentialy a placeholder/dummy one) was having its Message-ID used as the canonical References Message-ID for subsequent emails sent out to user_private_message recipients (such as members of the group), causing threading issues in the mail client. The canonical <topic/ID@HOST> format should be used instead for these cases. This commit fixes the issue by only using the IncomingEmail for the OP's Message-ID if the OP was created via our handle_mail email receiver pipeline. It does not make sense to use it in other cases.
This commit is contained in:
@ -24,11 +24,24 @@ describe Email::MessageIdService do
|
||||
|
||||
describe "#generate_for_topic" do
|
||||
it "generates for the topic using the message_id on the first post's incoming_email" do
|
||||
Fabricate(:incoming_email, message_id: "test213428@somemailservice.com", post: post)
|
||||
Fabricate(:incoming_email, message_id: "test213428@somemailservice.com", post: post, created_via: IncomingEmail.created_via_types[:handle_mail])
|
||||
post.reload
|
||||
expect(subject.generate_for_topic(topic, use_incoming_email_if_present: true)).to eq("<test213428@somemailservice.com>")
|
||||
end
|
||||
|
||||
it "does not use the first post's incoming email if it was created via group_smtp, only handle_mail" do
|
||||
incoming = Fabricate(
|
||||
:incoming_email,
|
||||
message_id: "test213428@somemailservice.com",
|
||||
post: post,
|
||||
created_via: IncomingEmail.created_via_types[:group_smtp]
|
||||
)
|
||||
post.reload
|
||||
expect(subject.generate_for_topic(topic, use_incoming_email_if_present: true)).to match(subject.message_id_topic_id_regexp)
|
||||
incoming.update(created_via: IncomingEmail.created_via_types[:handle_mail])
|
||||
expect(subject.generate_for_topic(topic, use_incoming_email_if_present: true)).to eq("<test213428@somemailservice.com>")
|
||||
end
|
||||
|
||||
it "generates for the topic without an incoming_email record" do
|
||||
expect(subject.generate_for_topic(topic)).to match(subject.message_id_topic_id_regexp)
|
||||
expect(subject.generate_for_topic(topic, use_incoming_email_if_present: true)).to match(subject.message_id_topic_id_regexp)
|
||||
|
Reference in New Issue
Block a user