From 73bf6983b90ce583677b38f404830971b8578b04 Mon Sep 17 00:00:00 2001 From: link2xt Date: Fri, 7 Nov 2025 16:22:34 +0000 Subject: [PATCH] fix: do not add QR inviter to groups immediately By the time you scan the QR code, inviter may not be in the group already. In this case securejoin protocol will never complete. If you then join the group in some other way, this results in you implicitly adding that inviter to the group. --- src/receive_imf.rs | 10 ++++++++++ src/securejoin/bob.rs | 11 ----------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/receive_imf.rs b/src/receive_imf.rs index 23ce8599d..f8d2b909b 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -2841,6 +2841,16 @@ async fn apply_group_changes( if !is_from_in_chat { better_msg = Some(String::new()); } else if let Some(key) = mime_parser.gossiped_keys.get(added_addr) { + if !chat_contacts.contains(&from_id) { + chat::add_to_chat_contacts_table( + context, + mime_parser.timestamp_sent, + chat.id, + &[from_id], + ) + .await?; + } + // TODO: if gossiped keys contain the same address multiple times, // we may lookup the wrong contact. // This can be fixed by looking at ChatGroupMemberAddedFpr, diff --git a/src/securejoin/bob.rs b/src/securejoin/bob.rs index fbe4446b6..123dc212c 100644 --- a/src/securejoin/bob.rs +++ b/src/securejoin/bob.rs @@ -126,17 +126,6 @@ pub(super) async fn start_protocol(context: &Context, invite: QrInvite) -> Resul match invite { QrInvite::Group { .. } => { let joining_chat_id = joining_chat_id(context, &invite, private_chat_id).await?; - // We created the group already, now we need to add Alice to the group. - // The group will only become usable once the protocol is finished. - if !is_contact_in_chat(context, joining_chat_id, invite.contact_id()).await? { - chat::add_to_chat_contacts_table( - context, - time(), - joining_chat_id, - &[invite.contact_id()], - ) - .await?; - } let msg = stock_str::secure_join_started(context, invite.contact_id()).await; chat::add_info_msg(context, joining_chat_id, &msg, time()).await?; Ok(joining_chat_id)