Skip to content

Commit

Permalink
fix: Add forgotten checks for Config::VerifiedOneOnOneChats
Browse files Browse the repository at this point in the history
  • Loading branch information
iequidoo committed Dec 12, 2023
1 parent ac3ba4d commit dade653
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
9 changes: 0 additions & 9 deletions python/tests/test_0_complex_or_slow.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,15 +652,6 @@ 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()
Expand Down
5 changes: 4 additions & 1 deletion src/receive_imf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2454,7 +2454,10 @@ async fn mark_recipients_as_verified(
peerstate.set_verified(PeerstateKeyType::GossipKey, fp, verifier_addr)?;
peerstate.save_to_db(&context.sql).await?;

if !is_verified {
if context
.get_config_bool(Config::VerifiedOneOnOneChats)
.await?
{
let (to_contact_id, _) = Contact::add_or_lookup(
context,
"",
Expand Down
17 changes: 11 additions & 6 deletions src/securejoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,12 +616,17 @@ pub(crate) async fn observe_securejoin_on_other_device(
peerstate.prefer_encrypt = EncryptPreference::Mutual;
peerstate.save_to_db(&context.sql).await.unwrap_or_default();

ChatId::set_protection_for_contact(
context,
contact_id,
mime_message.timestamp_sent,
)
.await?;
if context
.get_config_bool(Config::VerifiedOneOnOneChats)
.await?
{
ChatId::set_protection_for_contact(
context,
contact_id,
mime_message.timestamp_sent,
)
.await?;
}
} else if let Some(fingerprint) =
mime_message.get_header(HeaderDef::SecureJoinFingerprint)
{
Expand Down

0 comments on commit dade653

Please sign in to comment.