mirror of
https://github.com/chatmail/core.git
synced 2026-05-17 05:46:30 +03:00
prefer X-Microsoft-Original-Message-ID, if set
outlooks SMTP-server change the Message-ID of messages
and put the original Message-ID to X-Microsoft-Original-Message-ID.
the changed Message-ID has some issues:
- outgoing messages with bcc_self enabled are shown twice
as the self-copy got the changed Message-ID while the database uses
the original one
- read receipts do not work as they refer to the changed message id
- in general, sender and recipient see different Message-IDs
the issues can be fixed by
(1) let all receivers use the original Message-ID
this is what this pr is doing
and this should fix all issues with delta-to-delta communication,
including groups, group-images etc.
there may be issues left in communication
with other MUAs as they are using another Message-ID.
(2) ftr: updating the Message-ID in the database of the sender to the new one
this requires bcc_self always enabled (which is not the case)
and may also result easily in race conditions
(Bob answers before Alice sees its self-sent message),
however, has the advantage of better compatibility with other MUA.
if needed, the compatibility with other MUA could be improved by remembering
both Messages-IDs, maybe we could treat the modified as References or so,
however, i think, this could be part of another PR if we know better about
real, in the wild issues.
This commit is contained in:
@@ -11,11 +11,20 @@ pub enum HeaderDef {
|
|||||||
To,
|
To,
|
||||||
Cc,
|
Cc,
|
||||||
Disposition,
|
Disposition,
|
||||||
|
|
||||||
|
/// Used in the "Body Part Header" of MDNs as of RFC 8098.
|
||||||
|
/// Indicates the Message-ID of the message for which the MDN is being issued.
|
||||||
OriginalMessageId,
|
OriginalMessageId,
|
||||||
|
|
||||||
/// Delta Chat extension for message IDs in combined MDNs
|
/// Delta Chat extension for message IDs in combined MDNs
|
||||||
AdditionalMessageIds,
|
AdditionalMessageIds,
|
||||||
|
|
||||||
|
/// Outlook-SMTP-server replace the `Message-ID:`-header
|
||||||
|
/// and write the original ID to `X-Microsoft-Original-Message-ID`.
|
||||||
|
/// To sort things correctly and to not show outgoing messages twice,
|
||||||
|
/// we need to check that header as well.
|
||||||
|
XMicrosoftOriginalMessageId,
|
||||||
|
|
||||||
ListId,
|
ListId,
|
||||||
References,
|
References,
|
||||||
InReplyTo,
|
InReplyTo,
|
||||||
|
|||||||
@@ -514,12 +514,6 @@ impl<'a> MimeFactory<'a> {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// we could also store the message-id in the protected headers
|
|
||||||
// which would probably help to survive providers like
|
|
||||||
// Outlook.com or hotmail which mangle the Message-ID.
|
|
||||||
// but they also strip the Autocrypt header so we probably
|
|
||||||
// never get a chance to tunnel our protected headers in a
|
|
||||||
// cryptographic payload.
|
|
||||||
unprotected_headers.push(Header::new(
|
unprotected_headers.push(Header::new(
|
||||||
"Message-ID".into(),
|
"Message-ID".into(),
|
||||||
render_rfc724_mid(&rfc724_mid),
|
render_rfc724_mid(&rfc724_mid),
|
||||||
|
|||||||
@@ -950,7 +950,8 @@ impl MimeMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_rfc724_mid(&self) -> Option<String> {
|
pub fn get_rfc724_mid(&self) -> Option<String> {
|
||||||
self.get(HeaderDef::MessageId)
|
self.get(HeaderDef::XMicrosoftOriginalMessageId)
|
||||||
|
.or_else(|| self.get(HeaderDef::MessageId))
|
||||||
.and_then(|msgid| parse_message_id(msgid).ok())
|
.and_then(|msgid| parse_message_id(msgid).ok())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2749,4 +2750,27 @@ On 2020-10-25, Bob wrote:
|
|||||||
"mime-modified test – mime-modified *set*; simplify is always regarded as lossy."
|
"mime-modified test – mime-modified *set*; simplify is always regarded as lossy."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[async_std::test]
|
||||||
|
async fn test_x_microsoft_original_message_id() {
|
||||||
|
let t = TestContext::new().await;
|
||||||
|
let message = MimeMessage::from_bytes(&t, b"Date: Wed, 17 Feb 2021 15:45:15 +0000\n\
|
||||||
|
Chat-Version: 1.0\n\
|
||||||
|
Message-ID: <DBAPR03MB1180CE51A1BFE265BD018D4790869@DBAPR03MB6691.eurprd03.prod.outlook.com>\n\
|
||||||
|
To: Bob <bob@example.org>\n\
|
||||||
|
From: Alice <alice@example.org>\n\
|
||||||
|
Subject: Message from Alice\n\
|
||||||
|
Content-Type: text/plain\n\
|
||||||
|
X-Microsoft-Original-Message-ID: <Mr.6Dx7ITn4w38.n9j7epIcuQI@outlook.com>\n\
|
||||||
|
MIME-Version: 1.0\n\
|
||||||
|
\n\
|
||||||
|
Does it work with outlook now?\n\
|
||||||
|
")
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
message.get_rfc724_mid(),
|
||||||
|
Some("Mr.6Dx7ITn4w38.n9j7epIcuQI@outlook.com".to_string())
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user