mirror of
https://github.com/chatmail/core.git
synced 2026-05-04 22:06:29 +03:00
fix: create group chats unprotected on verification error
This commit is contained in:
@@ -2138,11 +2138,14 @@ async fn create_group(
|
||||
|
||||
let create_protected = if mime_parser.get_header(HeaderDef::ChatVerified).is_some() {
|
||||
if let VerifiedEncryption::NotVerified(err) = verified_encryption {
|
||||
warn!(context, "Verification problem: {err:#}.");
|
||||
let s = format!("{err}. See 'Info' for more details");
|
||||
mime_parser.replace_msg_by_error(&s);
|
||||
warn!(
|
||||
context,
|
||||
"Creating unprotected group because of the verification problem: {err:#}."
|
||||
);
|
||||
ProtectionStatus::Unprotected
|
||||
} else {
|
||||
ProtectionStatus::Protected
|
||||
}
|
||||
ProtectionStatus::Protected
|
||||
} else {
|
||||
ProtectionStatus::Unprotected
|
||||
};
|
||||
|
||||
@@ -918,12 +918,18 @@ async fn test_verified_member_added_reordering() -> Result<()> {
|
||||
let bob_sent_message = bob.send_text(bob_chat_id, "Hi").await;
|
||||
|
||||
// Fiona receives message from Bob before receiving
|
||||
// "Member added" message.
|
||||
// "Member added" message, so unverified group is created.
|
||||
let fiona_received_message = fiona.recv_msg(&bob_sent_message).await;
|
||||
assert_eq!(
|
||||
fiona_received_message.get_text(),
|
||||
"[The message was sent with non-verified encryption. See 'Info' for more details]"
|
||||
);
|
||||
let fiona_chat = Chat::load_from_db(fiona, fiona_received_message.chat_id).await?;
|
||||
|
||||
assert_eq!(fiona_received_message.get_text(), "Hi");
|
||||
assert_eq!(fiona_chat.is_protected(), false);
|
||||
|
||||
// Fiona receives late "Member added" message
|
||||
// and the chat becomes protected.
|
||||
fiona.recv_msg(&alice_sent_member_added).await;
|
||||
let fiona_chat = Chat::load_from_db(fiona, fiona_received_message.chat_id).await?;
|
||||
assert_eq!(fiona_chat.is_protected(), true);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user