diff --git a/src/chat.rs b/src/chat.rs index cc34d79ab..3e8f1ad7c 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -1999,7 +1999,9 @@ impl ChatIdBlocked { } let peerstate = Peerstate::from_addr(context, contact.get_addr()).await?; - let protected = peerstate.map_or(false, |p| p.is_using_verified_key()); + let protected = peerstate.map_or(false, |p| { + p.is_using_verified_key() && p.prefer_encrypt == EncryptPreference::Mutual + }); let smeared_time = create_smeared_timestamp(context); let chat_id = context diff --git a/src/tests/verified_chats.rs b/src/tests/verified_chats.rs index 352b1d3ab..e2c40e2a8 100644 --- a/src/tests/verified_chats.rs +++ b/src/tests/verified_chats.rs @@ -475,6 +475,43 @@ async fn test_break_protection_then_verify_again() -> Result<()> { Ok(()) } +/// Regression test: +/// - Verify a contact +/// - The contact stops using DC and sends a message from a classical MUA instead +/// - Delete the 1:1 chat +/// - Create a 1:1 chat +/// - Check that the created chat is not marked as protected +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn test_create_oneonone_chat_with_former_verified_contact() -> Result<()> { + let mut tcm = TestContextManager::new(); + let alice = tcm.alice().await; + let bob = tcm.bob().await; + enable_verified_oneonone_chats(&[&alice]).await; + + mark_as_verified(&alice, &bob).await; + + receive_imf( + &alice, + b"Subject: Message from bob\r\n\ + From: \r\n\ + To: \r\n\ + Date: Mon, 12 Dec 2022 14:33:39 +0000\r\n\ + Message-ID: \r\n\ + \r\n\ + Heyho!\r\n", + false, + ) + .await + .unwrap() + .unwrap(); + + alice.create_chat(&bob).await; + + assert_verified(&alice, &bob, ProtectionStatus::Unprotected).await; + + Ok(()) +} + // ============== Helper Functions ============== async fn assert_verified(this: &TestContext, other: &TestContext, protected: ProtectionStatus) {