mirror of
https://github.com/chatmail/core.git
synced 2026-05-07 17:06:35 +03:00
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:
@@ -1210,6 +1210,10 @@ class TestOnlineAccount:
|
|||||||
wait_securejoin_inviter_progress(ac1, 1000)
|
wait_securejoin_inviter_progress(ac1, 1000)
|
||||||
ac1._evtracker.get_matching("DC_EVENT_MEMBER_ADDED")
|
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):
|
def test_qr_verified_group_and_chatting(self, acfactory, lp):
|
||||||
ac1, ac2 = acfactory.get_two_online_accounts()
|
ac1, ac2 = acfactory.get_two_online_accounts()
|
||||||
lp.sec("ac1: create verified-group QR, ac2 scans and joins")
|
lp.sec("ac1: create verified-group QR, ac2 scans and joins")
|
||||||
|
|||||||
25
src/chat.rs
25
src/chat.rs
@@ -1883,7 +1883,14 @@ pub(crate) fn remove_from_chat_contacts_table(
|
|||||||
|
|
||||||
true
|
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()
|
"Cannot remove contact from chat; self not in group.".into()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} else if remove_from_chat_contacts_table(context, chat_id, contact_id) {
|
} else {
|
||||||
/* we should respect this - whatever we send to the group, it gets discarded anyway! */
|
|
||||||
if let Ok(contact) = Contact::get_by_id(context, contact_id) {
|
if let Ok(contact) = Contact::get_by_id(context, contact_id) {
|
||||||
if chat.is_promoted() {
|
if chat.is_promoted() {
|
||||||
msg.viewtype = Viewtype::Text;
|
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));
|
context.call_cb(Event::ChatModified(chat_id));
|
||||||
success = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,21 +106,6 @@ impl<'a, 'b> MimeFactory<'a, 'b> {
|
|||||||
|
|
||||||
let command = msg.param.get_cmd();
|
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
|
if command != SystemMessage::AutocryptSetupMessage
|
||||||
&& command != SystemMessage::SecurejoinMessage
|
&& command != SystemMessage::SecurejoinMessage
|
||||||
&& context.get_config_bool(Config::MdnsEnabled)
|
&& context.get_config_bool(Config::MdnsEnabled)
|
||||||
|
|||||||
Reference in New Issue
Block a user