cargo fmt

This commit is contained in:
holger krekel
2019-09-23 20:16:24 +02:00
parent 0759bdde01
commit e2fd22a78e
2 changed files with 75 additions and 67 deletions

View File

@@ -1347,7 +1347,10 @@ pub(crate) fn add_contact_to_chat_ex(
contact_id: u32,
from_handshake: bool,
) -> Result<bool, Error> {
ensure!(chat_id > DC_CHAT_ID_LAST_SPECIAL, "can not add member to special chats");
ensure!(
chat_id > DC_CHAT_ID_LAST_SPECIAL,
"can not add member to special chats"
);
let contact = Contact::get_by_id(context, contact_id)?;
let mut msg = Message::default();
@@ -1355,23 +1358,26 @@ pub(crate) fn add_contact_to_chat_ex(
/*this also makes sure, not contacts are added to special or normal chats*/
let mut chat = Chat::load_from_db(context, chat_id)?;
ensure!(real_group_exists(context, chat_id),
"chat_id {} is not a group where one can add members", chat_id);
ensure!(Contact::real_exists_by_id(context, contact_id) && contact_id != DC_CONTACT_ID_SELF,
"invalid contact_id {} for removal in group", contact_id);
ensure!(
real_group_exists(context, chat_id),
"chat_id {} is not a group where one can add members",
chat_id
);
ensure!(
Contact::real_exists_by_id(context, contact_id) && contact_id != DC_CONTACT_ID_SELF,
"invalid contact_id {} for removal in group",
contact_id
);
if !is_contact_in_chat(context, chat_id, DC_CONTACT_ID_SELF as u32) {
/* we should respect this - whatever we send to the group, it gets discarded anyway! */
emit_event!(
context,
Event::ErrorSelfNotInGroup(
"Cannot add contact to group; self not in group.".into()
)
Event::ErrorSelfNotInGroup("Cannot add contact to group; self not in group.".into())
);
bail!("can not add contact because our account is not part of it");
}
if from_handshake && chat.param.get_int(Param::Unpromoted).unwrap_or_default() == 1
{
if from_handshake && chat.param.get_int(Param::Unpromoted).unwrap_or_default() == 1 {
chat.param.remove(Param::Unpromoted);
chat.update_param(context).unwrap();
}

View File

@@ -522,7 +522,9 @@ pub fn handle_securejoin_handshake(
error!(context, "Chat {} not found.", &field_grpid);
return ret;
} else {
if let Err(err) = chat::add_contact_to_chat_ex(context, group_chat_id, contact_id, true) {
if let Err(err) =
chat::add_contact_to_chat_ex(context, group_chat_id, contact_id, true)
{
error!(context, "failed to add contact: {}", err);
}
}