mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 17:36:29 +03:00
refactor(remove_contact_from_chat): remove one level of indentation
This commit is contained in:
13
src/chat.rs
13
src/chat.rs
@@ -3920,11 +3920,13 @@ pub async fn remove_contact_from_chat(
|
||||
let mut msg = Message::default();
|
||||
|
||||
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 {
|
||||
bail!("Cannot remove members from non-group chats.");
|
||||
}
|
||||
|
||||
if !chat.is_self_in_chat(context).await? {
|
||||
let err_msg = format!(
|
||||
"Cannot remove contact {contact_id} from chat {chat_id}: self not in group."
|
||||
);
|
||||
let err_msg =
|
||||
format!("Cannot remove contact {contact_id} from chat {chat_id}: self not in group.");
|
||||
context.emit_event(EventType::ErrorSelfNotInGroup(err_msg.clone()));
|
||||
bail!("{}", err_msg);
|
||||
} else {
|
||||
@@ -3975,9 +3977,6 @@ pub async fn remove_contact_from_chat(
|
||||
chat.sync_contacts(context).await.log_err(context).ok();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
bail!("Cannot remove members from non-group chats.");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user