Skip to content

Commit c760e17

Browse files
authored
fix: no implicit member changes when we are added to the group (#6493)
1 parent 0df042a commit c760e17

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

src/receive_imf.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -2456,7 +2456,11 @@ async fn apply_group_changes(
24562456
if let Some(removed_id) = removed_id {
24572457
removed_ids.remove(&removed_id);
24582458
}
2459-
let group_changes_msgs = group_changes_msgs(context, &added_ids, &removed_ids, chat_id).await?;
2459+
let group_changes_msgs = if self_added {
2460+
Vec::new()
2461+
} else {
2462+
group_changes_msgs(context, &added_ids, &removed_ids, chat_id).await?
2463+
};
24602464

24612465
if let Some(avatar_action) = &mime_parser.group_avatar {
24622466
if !new_chat_contacts.contains(&ContactId::SELF) {

src/receive_imf/receive_imf_tests.rs

+31
Original file line numberDiff line numberDiff line change
@@ -5551,3 +5551,34 @@ async fn test_default_member_timestamps_to_zero() -> Result<()> {
55515551
assert_eq!(chat::get_chat_contacts(bob, chat.id).await?.len(), 3);
55525552
Ok(())
55535553
}
5554+
5555+
/// Regression test for the bug
5556+
/// that resulted in an info message
5557+
/// about Bob addition to the group on Fiona's device.
5558+
///
5559+
/// There should be no info messages about implicit
5560+
/// member changes when we are added to the group.
5561+
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
5562+
async fn test_two_group_securejoins() -> Result<()> {
5563+
let mut tcm = TestContextManager::new();
5564+
let alice = &tcm.alice().await;
5565+
let bob = &tcm.bob().await;
5566+
let fiona = &tcm.fiona().await;
5567+
5568+
let group_id = chat::create_group_chat(alice, ProtectionStatus::Protected, "Group").await?;
5569+
5570+
let qr = get_securejoin_qr(alice, Some(group_id)).await?;
5571+
5572+
// Bob joins using QR code.
5573+
tcm.exec_securejoin_qr(bob, alice, &qr).await;
5574+
5575+
// Fiona joins using QR code.
5576+
tcm.exec_securejoin_qr(fiona, alice, &qr).await;
5577+
5578+
let fiona_chat_id = fiona.get_last_msg().await.chat_id;
5579+
fiona
5580+
.golden_test_chat(fiona_chat_id, "two_group_securejoins")
5581+
.await;
5582+
5583+
Ok(())
5584+
}
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Group#Chat#11: Group [3 member(s)] 🛡️
2+
--------------------------------------------------------------------------------
3+
Msg#11: info (Contact#Contact#Info): [email protected] invited you to join this group.
4+
5+
Waiting for the device of [email protected] to reply… [NOTICED][INFO]
6+
Msg#13: info (Contact#Contact#Info): [email protected] replied, waiting for being added to the group… [NOTICED][INFO]
7+
Msg#17: info (Contact#Contact#Info): Messages are guaranteed to be end-to-end encrypted from now on. [NOTICED][INFO 🛡️]
8+
Msg#18🔒: (Contact#Contact#10): Member Me ([email protected]) added by [email protected]. [FRESH][INFO]
9+
--------------------------------------------------------------------------------

0 commit comments

Comments
 (0)