diff --git a/src/receive_imf.rs b/src/receive_imf.rs index 4a4f70f91..6abc92dd6 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -2456,7 +2456,11 @@ async fn apply_group_changes( if let Some(removed_id) = removed_id { removed_ids.remove(&removed_id); } - let group_changes_msgs = group_changes_msgs(context, &added_ids, &removed_ids, chat_id).await?; + let group_changes_msgs = if self_added { + Vec::new() + } else { + group_changes_msgs(context, &added_ids, &removed_ids, chat_id).await? + }; if let Some(avatar_action) = &mime_parser.group_avatar { if !new_chat_contacts.contains(&ContactId::SELF) { diff --git a/src/receive_imf/receive_imf_tests.rs b/src/receive_imf/receive_imf_tests.rs index f2798e9e9..409ea9937 100644 --- a/src/receive_imf/receive_imf_tests.rs +++ b/src/receive_imf/receive_imf_tests.rs @@ -5551,3 +5551,34 @@ async fn test_default_member_timestamps_to_zero() -> Result<()> { assert_eq!(chat::get_chat_contacts(bob, chat.id).await?.len(), 3); Ok(()) } + +/// Regression test for the bug +/// that resulted in an info message +/// about Bob addition to the group on Fiona's device. +/// +/// There should be no info messages about implicit +/// member changes when we are added to the group. +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn test_two_group_securejoins() -> Result<()> { + let mut tcm = TestContextManager::new(); + let alice = &tcm.alice().await; + let bob = &tcm.bob().await; + let fiona = &tcm.fiona().await; + + let group_id = chat::create_group_chat(alice, ProtectionStatus::Protected, "Group").await?; + + let qr = get_securejoin_qr(alice, Some(group_id)).await?; + + // Bob joins using QR code. + tcm.exec_securejoin_qr(bob, alice, &qr).await; + + // Fiona joins using QR code. + tcm.exec_securejoin_qr(fiona, alice, &qr).await; + + let fiona_chat_id = fiona.get_last_msg().await.chat_id; + fiona + .golden_test_chat(fiona_chat_id, "two_group_securejoins") + .await; + + Ok(()) +} diff --git a/test-data/golden/two_group_securejoins b/test-data/golden/two_group_securejoins new file mode 100644 index 000000000..5f66198ef --- /dev/null +++ b/test-data/golden/two_group_securejoins @@ -0,0 +1,9 @@ +Group#Chat#11: Group [3 member(s)] 🛡️ +-------------------------------------------------------------------------------- +Msg#11: info (Contact#Contact#Info): alice@example.org invited you to join this group. + +Waiting for the device of alice@example.org to reply… [NOTICED][INFO] +Msg#13: info (Contact#Contact#Info): alice@example.org replied, waiting for being added to the group… [NOTICED][INFO] +Msg#17: info (Contact#Contact#Info): Messages are guaranteed to be end-to-end encrypted from now on. [NOTICED][INFO 🛡️] +Msg#18🔒: (Contact#Contact#10): Member Me (fiona@example.net) added by alice@example.org. [FRESH][INFO] +--------------------------------------------------------------------------------