Skip to content

Commit aa46b07

Browse files
committed
feat: Do not copy Chat-Version header into outer part
Chat-Version is used sometimes by Sieve filters to move messages to DeltaChat folder: https://github.com/mailcow/mailcow-dockerized/blob/37beed6ad93f259b97cad41877982bce95295629/data/conf/dovecot/global_sieve_before This probably prevents notifications to MUAs that don't watch DeltaChat but watch INBOX. There are however disadvantages to exposing Chat-Version: 1. Spam filters may not like this header and it is difficult or impossible to tell if `Chat-Version` plays role in rejecting the message or delivering it into Spam folder. If there is no such header visible to the spam filter, this possibility can be ruled out. 2. Replies to chat messages may have no `Chat-Version` but have to be moved anyway. 3. The user may have no control over the Sieve filter, but it comes preconfigured in mailcow, so it is not possible to disable it on the client. Thanks to link2xt for providing this motivation. NOTE: Old Delta Chat will assign partially downloaded replies to an ad-hoc group with the sender instead of the 1:1 chat, but we're removing partial downloads anyway.
1 parent 148ff5a commit aa46b07

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

src/mimefactory.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -947,8 +947,7 @@ impl MimeFactory {
947947
//
948948
// These are standard headers such as Date, In-Reply-To, References, which cannot be placed
949949
// anywhere else according to the standard. Placing headers here also allows them to be fetched
950-
// individually over IMAP without downloading the message body. This is why Chat-Version is
951-
// placed here.
950+
// individually over IMAP without downloading the message body.
952951
let mut unprotected_headers: Vec<(&'static str, HeaderType<'static>)> = Vec::new();
953952

954953
// Headers that MUST NOT (only) go into IMF header section:
@@ -1063,11 +1062,7 @@ impl MimeFactory {
10631062
mail_builder::headers::raw::Raw::new("[...]").into(),
10641063
));
10651064
}
1066-
"in-reply-to"
1067-
| "references"
1068-
| "auto-submitted"
1069-
| "chat-version"
1070-
| "autocrypt-setup-message" => {
1065+
"in-reply-to" | "references" | "auto-submitted" | "autocrypt-setup-message" => {
10711066
unprotected_headers.push(header.clone());
10721067
}
10731068
_ => {

src/receive_imf.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2414,7 +2414,14 @@ async fn lookup_chat_by_reply(
24142414

24152415
// If this was a private message just to self, it was probably a private reply.
24162416
// It should not go into the group then, but into the private chat.
2417-
if is_probably_private_reply(context, mime_parser, parent_chat_id).await? {
2417+
if is_probably_private_reply(
2418+
context,
2419+
mime_parser,
2420+
is_partial_download.is_some(),
2421+
parent_chat_id,
2422+
)
2423+
.await?
2424+
{
24182425
return Ok(None);
24192426
}
24202427

@@ -2561,6 +2568,7 @@ async fn lookup_or_create_adhoc_group(
25612568
async fn is_probably_private_reply(
25622569
context: &Context,
25632570
mime_parser: &MimeMessage,
2571+
is_partial_download: bool,
25642572
parent_chat_id: ChatId,
25652573
) -> Result<bool> {
25662574
// Message cannot be a private reply if it has an explicit Chat-Group-ID header.
@@ -2579,7 +2587,7 @@ async fn is_probably_private_reply(
25792587
return Ok(false);
25802588
}
25812589

2582-
if !mime_parser.has_chat_version() {
2590+
if !is_partial_download && !mime_parser.has_chat_version() {
25832591
let chat_contacts = chat::get_chat_contacts(context, parent_chat_id).await?;
25842592
if chat_contacts.len() == 2 && chat_contacts.contains(&ContactId::SELF) {
25852593
return Ok(false);

0 commit comments

Comments
 (0)