Skip to content

Commit 1219cbe

Browse files
committed
fix: do not create 1:1 chat on second device when scanning a QR code
This avoids creating 1:1 chat on a second device when joining a channel. Now when joining a channel there may be no 1:1 chat with the inviter when the channel is created. In this case we still create the channel as unblocked even if 1:1 chat would be a contact request because joining the channel is an explicit action and it is not possible to add someone who did not scan a QR to the channel manually.
1 parent bc48b17 commit 1219cbe

File tree

4 files changed

+10
-16
lines changed

4 files changed

+10
-16
lines changed

python/tests/test_0_complex_or_slow.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ def test_use_new_verified_group_after_going_online(acfactory, data, tmp_path, lp
288288
assert open(contact.get_profile_image(), "rb").read() == open(avatar_path, "rb").read()
289289

290290
lp.sec("ac2_offl: sending message")
291+
chat2.accept()
291292
msg_out = chat2.send_text("hello")
292293

293294
lp.sec("ac1: receiving message")

src/chat/chat_tests.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3768,14 +3768,7 @@ async fn test_leave_broadcast_multidevice() -> Result<()> {
37683768
// The contact should be marked as verified.
37693769
check_direct_chat_is_hidden_and_contact_is_verified(alice, bob0).await;
37703770
check_direct_chat_is_hidden_and_contact_is_verified(bob0, alice).await;
3771-
3772-
// TODO: There is a known bug in `observe_securejoin_on_other_device()`:
3773-
// When Bob joins a group or broadcast with his first device,
3774-
// then a chat with Alice will pop up on his second device.
3775-
// When it's fixed, the 2 following lines can be replaced with
3776-
// `check_direct_chat_is_hidden_and_contact_is_verified(bob1, alice).await;`
3777-
let bob1_alice_contact = bob1.add_or_lookup_contact_no_key(alice).await;
3778-
assert!(bob1_alice_contact.is_verified(bob1).await.unwrap());
3771+
check_direct_chat_is_hidden_and_contact_is_verified(bob1, alice).await;
37793772

37803773
tcm.section("Alice sends first message to broadcast.");
37813774
let sent_msg = alice.send_text(alice_chat_id, "Hello!").await;

src/receive_imf.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3562,7 +3562,14 @@ async fn create_or_lookup_mailinglist_or_broadcast(
35623562
chattype,
35633563
&listid,
35643564
name,
3565-
create_blocked,
3565+
if chattype == Chattype::InBroadcast {
3566+
// If we joined the broadcast, we have scanned a QR code.
3567+
// Even if 1:1 chat does not exist or is in a contact request,
3568+
// create the channel as unblocked.
3569+
Blocked::Not
3570+
} else {
3571+
create_blocked
3572+
},
35663573
param,
35673574
mime_parser.timestamp_sent,
35683575
)

src/securejoin.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -839,13 +839,6 @@ pub(crate) async fn observe_securejoin_on_other_device(
839839
inviter_progress(context, contact_id, chat_id, chat_type)?;
840840
}
841841

842-
if matches!(step, SecureJoinStep::RequestWithAuth) {
843-
// This actually reflects what happens on the first device (which does the secure
844-
// join) and causes a subsequent "vg-member-added" message to create an unblocked
845-
// verified group.
846-
ChatId::create_for_contact_with_blocked(context, contact_id, Blocked::Not).await?;
847-
}
848-
849842
if matches!(step, SecureJoinStep::MemberAdded) {
850843
Ok(HandshakeMessage::Propagate)
851844
} else {

0 commit comments

Comments
 (0)