fix: Revert member addition if the corresponding message couldn't be sent (#5508)

This commit is contained in:
iequidoo
2024-05-31 12:45:54 -03:00
committed by iequidoo
parent 24a06d175e
commit 0a0e7156e0
2 changed files with 17 additions and 2 deletions

View File

@@ -3760,7 +3760,10 @@ pub(crate) async fn add_contact_to_chat_ex(
msg.param.set_cmd(SystemMessage::MemberAddedToGroup);
msg.param.set(Param::Arg, contact_addr);
msg.param.set_int(Param::Arg2, from_handshake.into());
msg.id = send_msg(context, chat_id, &mut msg).await?;
if let Err(e) = send_msg(context, chat_id, &mut msg).await {
remove_from_chat_contacts_table(context, chat_id, contact_id).await?;
return Err(e);
}
sync = Nosync;
}
context.emit_event(EventType::ChatModified(chat_id));