From fdd239f61f63d872913b205d34d9d2c39e163a1f Mon Sep 17 00:00:00 2001 From: link2xt Date: Sat, 2 Dec 2023 20:12:16 +0000 Subject: [PATCH] fix: narrow the scope of verification exception to 1:1 chats Allowing outgoing unencrypted messages in groups with 2 members breaks the test `python/tests/test_0_complex_or_slow.py::test_verified_group_vs_delete_server_after` --- src/receive_imf.rs | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/receive_imf.rs b/src/receive_imf.rs index 13234fa0d..a669ec711 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -1092,7 +1092,15 @@ async fn add_parts( if !chat_id.is_special() && is_partial_download.is_none() { let chat = Chat::load_from_db(context, chat_id).await?; - if chat.is_protected() { + // For outgoing emails in the 1:1 chat we have an exception that + // they are allowed to be unencrypted: + // 1. They can't be an attack (they are outgoing, not incoming) + // 2. Probably the unencryptedness is just a temporary state, after all + // the user obviously still uses DC + // -> Showing info messages everytime would be a lot of noise + // 3. The info messages that are shown to the user ("Your chat partner + // likely reinstalled DC" or similar) would be wrong. + if chat.is_protected() && (incoming || chat.typ != Chattype::Single) { if let VerifiedEncryption::NotVerified(err) = verified_encryption { warn!(context, "Verification problem: {err:#}."); let s = format!("{err}. See 'Info' for more details"); @@ -2395,19 +2403,6 @@ async fn has_verified_encryption( .filter(|id| *id != ContactId::SELF) .collect::>(); - if from_id == ContactId::SELF && to_ids.len() <= 1 { - // For outgoing emails in the 1:1 chat and groups with 2 members, - // we have an exception that - // they are allowed to be unencrypted: - // 1. They can't be an attack (they are outgoing, not incoming) - // 2. Probably the unencryptedness is just a temporary state, after all - // the user obviously still uses DC - // -> Showing info messages everytime would be a lot of noise - // 3. The info messages that are shown to the user ("Your chat partner - // likely reinstalled DC" or similar) would be wrong. - return Ok(Verified); - } - if !mimeparser.was_encrypted() { return Ok(NotVerified("This message is not encrypted".to_string())); };