mirror of
https://github.com/chatmail/core.git
synced 2026-05-02 21:06:31 +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 mut msg = Message::default();
|
||||||
|
|
||||||
let 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 {
|
||||||
|
bail!("Cannot remove members from non-group chats.");
|
||||||
|
}
|
||||||
|
|
||||||
if !chat.is_self_in_chat(context).await? {
|
if !chat.is_self_in_chat(context).await? {
|
||||||
let err_msg = format!(
|
let err_msg =
|
||||||
"Cannot remove contact {contact_id} from chat {chat_id}: self not in group."
|
format!("Cannot remove contact {contact_id} from chat {chat_id}: self not in group.");
|
||||||
);
|
|
||||||
context.emit_event(EventType::ErrorSelfNotInGroup(err_msg.clone()));
|
context.emit_event(EventType::ErrorSelfNotInGroup(err_msg.clone()));
|
||||||
bail!("{}", err_msg);
|
bail!("{}", err_msg);
|
||||||
} else {
|
} else {
|
||||||
@@ -3975,9 +3977,6 @@ pub async fn remove_contact_from_chat(
|
|||||||
chat.sync_contacts(context).await.log_err(context).ok();
|
chat.sync_contacts(context).await.log_err(context).ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
bail!("Cannot remove members from non-group chats.");
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user