refactor(remove_contact_from_chat): remove one level of indentation

This commit is contained in:
link2xt
2024-10-19 22:25:29 +00:00
parent 1b824705fd
commit 95c252a5a6

View File

@@ -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(())
}