Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions src/receive_imf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2866,15 +2866,6 @@ async fn apply_group_changes(
let (mut removed_id, mut added_id) = (None, None);
let mut better_msg = None;
let mut silent = false;

// True if a Delta Chat client has explicitly added our current primary address.
let self_added =
if let Some(added_addr) = mime_parser.get_header(HeaderDef::ChatGroupMemberAdded) {
addr_cmp(&context.get_primary_self_addr().await?, added_addr)
} else {
false
};

let chat_contacts =
HashSet::<ContactId>::from_iter(chat::get_chat_contacts(context, chat.id).await?);
let is_from_in_chat =
Expand Down Expand Up @@ -3004,6 +2995,15 @@ async fn apply_group_changes(
.await?;
} else {
let mut new_members: HashSet<ContactId>;
// True if a Delta Chat client has explicitly and really added our primary address to an
// already existing group.
let self_added =
if let Some(added_addr) = mime_parser.get_header(HeaderDef::ChatGroupMemberAdded) {
addr_cmp(&context.get_primary_self_addr().await?, added_addr)
&& !chat_contacts.contains(&ContactId::SELF)
} else {
false
};
if self_added {
new_members = HashSet::from_iter(to_ids_flat.iter().copied());
new_members.insert(ContactId::SELF);
Expand Down Expand Up @@ -3070,17 +3070,18 @@ async fn apply_group_changes(
.collect();

if let Some(added_id) = added_id {
if !added_ids.remove(&added_id) && !self_added {
// No-op "Member added" message.
//
// Trash it.
if !added_ids.remove(&added_id) && added_id != ContactId::SELF {
// No-op "Member added" message. An exception is self-addition messages because they at
// least must be shown when a chat is created on our side.
better_msg = Some(String::new());
}
}
if let Some(removed_id) = removed_id {
removed_ids.remove(&removed_id);
}
let group_changes_msgs = if self_added {
let group_changes_msgs = if !chat_contacts.contains(&ContactId::SELF)
&& new_chat_contacts.contains(&ContactId::SELF)
{
Vec::new()
} else {
group_changes_msgs(context, &added_ids, &removed_ids, chat.id).await?
Expand Down
7 changes: 6 additions & 1 deletion src/tests/verified_chats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,12 @@ async fn test_verified_chat_editor_reordering() -> Result<()> {

tcm.section("Charlie receives member added message");
charlie.recv_msg(&sent_member_added_msg).await;

charlie
.golden_test_chat(
charlie_received_xdc.chat_id,
"verified_chats_editor_reordering",
)
.await;
Ok(())
}

Expand Down
11 changes: 11 additions & 0 deletions test-data/golden/verified_chats_editor_reordering
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
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#16🔒: (Contact#Contact#11): [FRESH]
Msg#18: info (Contact#Contact#Info): Messages are end-to-end encrypted. [NOTICED][INFO 🛡️]
Msg#19: info (Contact#Contact#Info): Member bob@example.net added. [NOTICED][INFO]
Msg#20🔒: (Contact#Contact#10): Member Me added by alice@example.org. [FRESH][INFO]
--------------------------------------------------------------------------------
Loading