Skip to content

Commit 3783b8a

Browse files
committed
Do not try to revert adding members if Member added message is not sent
This operation may itself fail and with timestamps reverting addition is non-trivial.
1 parent b0d10da commit 3783b8a

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/chat.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3728,10 +3728,8 @@ pub(crate) async fn add_contact_to_chat_ex(
37283728
msg.param.set_cmd(SystemMessage::MemberAddedToGroup);
37293729
msg.param.set(Param::Arg, contact_addr);
37303730
msg.param.set_int(Param::Arg2, from_handshake.into());
3731-
if let Err(e) = send_msg(context, chat_id, &mut msg).await {
3732-
remove_from_chat_contacts_table(context, chat_id, contact_id).await?;
3733-
return Err(e);
3734-
}
3731+
send_msg(context, chat_id, &mut msg).await?;
3732+
37353733
sync = Nosync;
37363734
// TODO: Remove this compat code needed because Core <= v1.143:
37373735
// - doesn't accept synchronization of QR code tokens for unpromoted groups, so we also send

src/receive_imf/tests.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4931,7 +4931,10 @@ async fn test_protected_group_add_remove_member_missing_key() -> Result<()> {
49314931
assert!(add_contact_to_chat(alice, group_id, alice_fiona_id)
49324932
.await
49334933
.is_err());
4934-
assert!(!is_contact_in_chat(alice, group_id, alice_fiona_id).await?);
4934+
// Sending the message failed,
4935+
// but member is added to the chat locally already.
4936+
assert!(is_contact_in_chat(alice, group_id, alice_fiona_id).await?);
4937+
49354938
// Now the chat has a message "You added member fiona@example.net. [INFO] !!" (with error) that
49364939
// may be confusing, but if the error is displayed in UIs, it's more or less ok. This is not a
49374940
// normal scenario anyway.

0 commit comments

Comments
 (0)