fix bug in that remove-contact failed on new groups where we didn't have the peerstate of the removed-contact yet

This commit is contained in:
holger krekel
2020-04-13 11:56:36 +02:00
parent 323d996d5f
commit 1855f84fe0
3 changed files with 24 additions and 20 deletions

View File

@@ -1210,6 +1210,10 @@ class TestOnlineAccount:
wait_securejoin_inviter_progress(ac1, 1000)
ac1._evtracker.get_matching("DC_EVENT_MEMBER_ADDED")
ch.remove_contact(ac1.get_self_contact())
ac2._evtracker.get_matching("DC_EVENT_MEMBER_REMOVED")
ac1._evtracker.get_matching("DC_EVENT_MEMBER_REMOVED")
def test_qr_verified_group_and_chatting(self, acfactory, lp):
ac1, ac2 = acfactory.get_two_online_accounts()
lp.sec("ac1: create verified-group QR, ac2 scans and joins")

View File

@@ -1883,7 +1883,14 @@ pub(crate) fn remove_from_chat_contacts_table(
true
}
Err(_) => false,
Err(_) => {
warn!(
context,
"could not remove contact {:?} from chat {:?}", contact_id, chat_id
);
false
}
}
}
@@ -2161,8 +2168,7 @@ pub fn remove_contact_from_chat(
"Cannot remove contact from chat; self not in group.".into()
)
);
} else if remove_from_chat_contacts_table(context, chat_id, contact_id) {
/* we should respect this - whatever we send to the group, it gets discarded anyway! */
} else {
if let Ok(contact) = Contact::get_by_id(context, contact_id) {
if chat.is_promoted() {
msg.viewtype = Viewtype::Text;
@@ -2191,9 +2197,18 @@ pub fn remove_contact_from_chat(
});
}
}
// we remove the member from the chat after constructing the
// to-be-send message. If between send_msg() and here the
// process dies the user will have to re-do the action. It's
// better than the other way round: you removed
// someone from DB but no peer or device gets to know about it and
// group membership is thus different on different devices.
// Note also that sending a message needs all recipients
// in order to correctly determine encryption so if we
// removed it first, it would complicate the
// check/encryption logic.
success = remove_from_chat_contacts_table(context, chat_id, contact_id);
context.call_cb(Event::ChatModified(chat_id));
success = true;
}
}
}

View File

@@ -106,21 +106,6 @@ impl<'a, 'b> MimeFactory<'a, 'b> {
let command = msg.param.get_cmd();
/* for added members, the list is just fine */
if command == SystemMessage::MemberRemovedFromGroup {
let email_to_remove = msg.param.get(Param::Arg).unwrap_or_default();
let self_addr = context
.get_config(Config::ConfiguredAddr)
.unwrap_or_default();
if !email_to_remove.is_empty()
&& !addr_cmp(email_to_remove, self_addr)
&& !recipients_contain_addr(&recipients, &email_to_remove)
{
recipients.push(("".to_string(), email_to_remove.to_string()));
}
}
if command != SystemMessage::AutocryptSetupMessage
&& command != SystemMessage::SecurejoinMessage
&& context.get_config_bool(Config::MdnsEnabled)