Fix all outgoing messages popping up in selfchat (#2456)

Fix https://github.com/deltachat/deltachat-android/issues/1940, fix https://github.com/deltachat/deltachat-core-rust/issues/2220 (I assume these are the same bug)

The problem was:
- Gmail adds a header `Bcc: <self-address>` to our bcc-self message
- `to_id` was just set to the first recipient, in this case _self_
- it was seen that `to_id` is _self_, so it's a self-sent message
This commit is contained in:
Hocuri
2021-05-28 20:02:46 +02:00
committed by GitHub
parent 46e901be78
commit e3e2adeea5
2 changed files with 30 additions and 1 deletions

View File

@@ -3986,4 +3986,33 @@ YEAAAAAA!.
.await,
);
}
#[async_std::test]
async fn test_dont_show_all_outgoing_msgs_in_self_chat() {
// Regression test for https://github.com/deltachat/deltachat-android/issues/1940:
// Some servers add a `Bcc: <Self>` header, which caused all outgoing messages to
// be shown in the self-chat.
let t = TestContext::new_alice().await;
dc_receive_imf(
&t,
b"Bcc: alice@example.com
Received: from [127.0.0.1]
Subject: s
Chat-Version: 1.0
Message-ID: <abcd@gmail.com>
To: <me@other.maildomain.com>
From: <alice@example.com>
Message content",
"Inbox",
1,
false,
)
.await
.unwrap();
let msg = t.get_last_msg().await;
assert_ne!(msg.chat_id, t.get_self_chat().await.id);
}
}

View File

@@ -1585,7 +1585,7 @@ fn get_attachment_filename(
/// Returned addresses are normalized and lowercased.
pub(crate) fn get_recipients(headers: &[MailHeader]) -> Vec<SingleInfo> {
get_all_addresses_from_header(headers, |header_key| {
header_key == "to" || header_key == "cc" || header_key == "bcc"
header_key == "to" || header_key == "cc"
})
}