mirror of
https://github.com/chatmail/core.git
synced 2026-05-09 01:46:30 +03:00
fix: Don't create 1:1 chat as protected for contact who doesn't prefer to encrypt (#4538)
This commit is contained in:
@@ -1999,7 +1999,9 @@ impl ChatIdBlocked {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let peerstate = Peerstate::from_addr(context, contact.get_addr()).await?;
|
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 smeared_time = create_smeared_timestamp(context);
|
||||||
|
|
||||||
let chat_id = context
|
let chat_id = context
|
||||||
|
|||||||
@@ -475,6 +475,43 @@ async fn test_break_protection_then_verify_again() -> Result<()> {
|
|||||||
Ok(())
|
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: <bob@example.net>\r\n\
|
||||||
|
To: <alice@example.org>\r\n\
|
||||||
|
Date: Mon, 12 Dec 2022 14:33:39 +0000\r\n\
|
||||||
|
Message-ID: <abcd@example.net>\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 ==============
|
// ============== Helper Functions ==============
|
||||||
|
|
||||||
async fn assert_verified(this: &TestContext, other: &TestContext, protected: ProtectionStatus) {
|
async fn assert_verified(this: &TestContext, other: &TestContext, protected: ProtectionStatus) {
|
||||||
|
|||||||
Reference in New Issue
Block a user