mirror of
https://github.com/chatmail/core.git
synced 2026-05-25 09:46:31 +03:00
fix(remove_contact_from_chat): bubble up chat loading errors
This commit is contained in:
12
src/chat.rs
12
src/chat.rs
@@ -3182,7 +3182,7 @@ pub async fn remove_contact_from_chat(
|
||||
let mut msg = Message::default();
|
||||
let mut success = false;
|
||||
|
||||
if let Ok(chat) = Chat::load_from_db(context, chat_id).await {
|
||||
let chat = Chat::load_from_db(context, chat_id).await?;
|
||||
if chat.typ == Chattype::Group || chat.typ == Chattype::Broadcast {
|
||||
if !chat.is_self_in_chat(context).await? {
|
||||
context.emit_event(EventType::ErrorSelfNotInGroup(
|
||||
@@ -3197,15 +3197,10 @@ pub async fn remove_contact_from_chat(
|
||||
msg.viewtype = Viewtype::Text;
|
||||
if contact.id == ContactId::SELF {
|
||||
set_group_explicitly_left(context, &chat.grpid).await?;
|
||||
msg.text =
|
||||
Some(stock_str::msg_group_left(context, ContactId::SELF).await);
|
||||
msg.text = Some(stock_str::msg_group_left(context, ContactId::SELF).await);
|
||||
} else {
|
||||
msg.text = Some(
|
||||
stock_str::msg_del_member(
|
||||
context,
|
||||
contact.get_addr(),
|
||||
ContactId::SELF,
|
||||
)
|
||||
stock_str::msg_del_member(context, contact.get_addr(), ContactId::SELF)
|
||||
.await,
|
||||
);
|
||||
}
|
||||
@@ -3230,7 +3225,6 @@ pub async fn remove_contact_from_chat(
|
||||
context.emit_event(EventType::ChatModified(chat_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !success {
|
||||
bail!("Failed to remove contact");
|
||||
|
||||
Reference in New Issue
Block a user