Skip to content

Commit

Permalink
feat: add more context to remove_contact_from_chat errors
Browse files Browse the repository at this point in the history
  • Loading branch information
link2xt committed Oct 19, 2024
1 parent 5efd0cf commit a7e4085
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3949,12 +3949,19 @@ pub async fn remove_contact_from_chat(
}
msg.param.set_cmd(SystemMessage::MemberRemovedFromGroup);
msg.param.set(Param::Arg, contact.get_addr().to_lowercase());
let res = send_msg(context, chat_id, &mut msg).await;
let res = send_msg(context, chat_id, &mut msg)
.await
.context("Failed to send member removed message");
if contact_id == ContactId::SELF {
res?;
set_group_explicitly_left(context, &chat.grpid).await?;
set_group_explicitly_left(context, &chat.grpid)
.await
.context("Failed to mark group as explicitly left")?;
} else if let Err(e) = res {
warn!(context, "remove_contact_from_chat({chat_id}, {contact_id}): send_msg() failed: {e:#}.");
warn!(
context,
"remove_contact_from_chat({chat_id}, {contact_id}): {e:#}."
);
}
} else {
sync = Sync;
Expand All @@ -3971,7 +3978,9 @@ pub async fn remove_contact_from_chat(
// in order to correctly determine encryption so if we
// removed it first, it would complicate the
// check/encryption logic.
remove_from_chat_contacts_table(context, chat_id, contact_id).await?;
remove_from_chat_contacts_table(context, chat_id, contact_id)
.await
.context("Failed to remove contact from chats_contacts table")?;
context.emit_event(EventType::ChatModified(chat_id));
if sync.into() {
chat.sync_contacts(context).await.log_err(context).ok();
Expand Down

0 comments on commit a7e4085

Please sign in to comment.