mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 01:16: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 msg = Message::default();
|
||||||
let mut success = false;
|
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.typ == Chattype::Group || chat.typ == Chattype::Broadcast {
|
||||||
if !chat.is_self_in_chat(context).await? {
|
if !chat.is_self_in_chat(context).await? {
|
||||||
context.emit_event(EventType::ErrorSelfNotInGroup(
|
context.emit_event(EventType::ErrorSelfNotInGroup(
|
||||||
@@ -3197,15 +3197,10 @@ pub async fn remove_contact_from_chat(
|
|||||||
msg.viewtype = Viewtype::Text;
|
msg.viewtype = Viewtype::Text;
|
||||||
if contact.id == ContactId::SELF {
|
if contact.id == ContactId::SELF {
|
||||||
set_group_explicitly_left(context, &chat.grpid).await?;
|
set_group_explicitly_left(context, &chat.grpid).await?;
|
||||||
msg.text =
|
msg.text = Some(stock_str::msg_group_left(context, ContactId::SELF).await);
|
||||||
Some(stock_str::msg_group_left(context, ContactId::SELF).await);
|
|
||||||
} else {
|
} else {
|
||||||
msg.text = Some(
|
msg.text = Some(
|
||||||
stock_str::msg_del_member(
|
stock_str::msg_del_member(context, contact.get_addr(), ContactId::SELF)
|
||||||
context,
|
|
||||||
contact.get_addr(),
|
|
||||||
ContactId::SELF,
|
|
||||||
)
|
|
||||||
.await,
|
.await,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -3230,7 +3225,6 @@ pub async fn remove_contact_from_chat(
|
|||||||
context.emit_event(EventType::ChatModified(chat_id));
|
context.emit_event(EventType::ChatModified(chat_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if !success {
|
if !success {
|
||||||
bail!("Failed to remove contact");
|
bail!("Failed to remove contact");
|
||||||
|
|||||||
Reference in New Issue
Block a user