diff --git a/python/tests/test_0_complex_or_slow.py b/python/tests/test_0_complex_or_slow.py index 75c554a6d..af7f3b8da 100644 --- a/python/tests/test_0_complex_or_slow.py +++ b/python/tests/test_0_complex_or_slow.py @@ -647,6 +647,15 @@ def test_verified_group_vs_delete_server_after(acfactory, tmp_path, lp): chat2.send_text("hi2") lp.sec("ac2_offl: receiving message") + ev = ac2_offl._evtracker.get_matching("DC_EVENT_INCOMING_MSG|DC_EVENT_MSGS_CHANGED") + msg_in = ac2_offl.get_message_by_id(ev.data2) + assert msg_in.is_system_message() + assert msg_in.text == "Messages are guaranteed to be end-to-end encrypted from now on." + + # We need to consume one event that has data2=0 + ev = ac2_offl._evtracker.get_matching("DC_EVENT_INCOMING_MSG|DC_EVENT_MSGS_CHANGED") + assert ev.data2 == 0 + ev = ac2_offl._evtracker.get_matching("DC_EVENT_INCOMING_MSG|DC_EVENT_MSGS_CHANGED") msg_in = ac2_offl.get_message_by_id(ev.data2) assert not msg_in.is_system_message() diff --git a/src/securejoin.rs b/src/securejoin.rs index 7f88ae39b..71336ac5a 100644 --- a/src/securejoin.rs +++ b/src/securejoin.rs @@ -606,14 +606,11 @@ pub(crate) async fn observe_securejoin_on_other_device( return Ok(HandshakeMessage::Ignore); } }; - if !peerstate.is_using_verified_key() { - // The `if` is purely for performance: - // If the verified key was used already, then the 1:1 chat was already protected. - ChatId::set_protection_for_contact(context, contact_id).await?; - } peerstate.set_verified(PeerstateKeyType::GossipKey, fingerprint, addr)?; peerstate.prefer_encrypt = EncryptPreference::Mutual; peerstate.save_to_db(&context.sql).await.unwrap_or_default(); + + ChatId::set_protection_for_contact(context, contact_id).await?; } else if let Some(fingerprint) = mime_message.get_header(HeaderDef::SecureJoinFingerprint) { diff --git a/src/tests/verified_chats.rs b/src/tests/verified_chats.rs index 413338929..03c025ba2 100644 --- a/src/tests/verified_chats.rs +++ b/src/tests/verified_chats.rs @@ -131,7 +131,7 @@ async fn test_create_verified_oneonone_chat() -> Result<()> { let chat = alice.create_chat(&fiona).await; assert!(chat.is_protected()); - let msg = alice.get_last_msg().await; + let msg = alice.get_last_msg_in(chat.id).await; let expected_text = stock_str::chat_protection_enabled(&alice).await; assert_eq!(msg.text, expected_text); }