mirror of
https://github.com/chatmail/core.git
synced 2026-04-21 15:36:30 +03:00
feat: do not replace messages with an error on verification failure
This commit is contained in:
@@ -1582,15 +1582,6 @@ impl MimeMessage {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn replace_msg_by_error(&mut self, error_msg: &str) {
|
||||
self.is_system_message = SystemMessage::Unknown;
|
||||
if let Some(part) = self.parts.first_mut() {
|
||||
part.typ = Viewtype::Text;
|
||||
part.msg = format!("[{error_msg}]");
|
||||
self.parts.truncate(1);
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn get_rfc724_mid(&self) -> Option<String> {
|
||||
self.get_header(HeaderDef::MessageId)
|
||||
.and_then(|msgid| parse_message_id(msgid).ok())
|
||||
|
||||
@@ -1864,25 +1864,6 @@ async fn add_parts(
|
||||
None
|
||||
};
|
||||
|
||||
let mut verification_failed = false;
|
||||
if !chat_id.is_special() && is_partial_download.is_none() {
|
||||
// For outgoing emails in the 1:1 chat we have an exception that
|
||||
// they are allowed to be unencrypted:
|
||||
// 1. They can't be an attack (they are outgoing, not incoming)
|
||||
// 2. Probably the unencryptedness is just a temporary state, after all
|
||||
// the user obviously still uses DC
|
||||
// -> Showing info messages every time would be a lot of noise
|
||||
// 3. The info messages that are shown to the user ("Your chat partner
|
||||
// likely reinstalled DC" or similar) would be wrong.
|
||||
if chat.is_protected() && (mime_parser.incoming || chat.typ != Chattype::Single) {
|
||||
if let VerifiedEncryption::NotVerified(err) = verified_encryption {
|
||||
verification_failed = true;
|
||||
warn!(context, "Verification problem: {err:#}.");
|
||||
let s = format!("{err}. Re-download the message or see 'Info' for more details");
|
||||
mime_parser.replace_msg_by_error(&s);
|
||||
}
|
||||
}
|
||||
}
|
||||
drop(chat); // Avoid using stale `chat` object.
|
||||
|
||||
let sort_timestamp = tweak_sort_timestamp(
|
||||
@@ -2156,10 +2137,6 @@ RETURNING id
|
||||
DownloadState::Available
|
||||
} else if mime_parser.decrypting_failed {
|
||||
DownloadState::Undecipherable
|
||||
} else if verification_failed {
|
||||
// Verification can fail because of message reordering. Re-downloading the
|
||||
// message should help if so.
|
||||
DownloadState::Available
|
||||
} else {
|
||||
DownloadState::Done
|
||||
},
|
||||
|
||||
@@ -5133,21 +5133,9 @@ async fn test_unverified_member_msg() -> Result<()> {
|
||||
let fiona_chat_id = fiona.get_last_msg().await.chat_id;
|
||||
let fiona_sent_msg = fiona.send_text(fiona_chat_id, "Hi").await;
|
||||
|
||||
// The message can't be verified, but the user can re-download it.
|
||||
let bob_msg = bob.recv_msg(&fiona_sent_msg).await;
|
||||
assert_eq!(bob_msg.download_state, DownloadState::Available);
|
||||
assert!(
|
||||
bob_msg
|
||||
.text
|
||||
.contains("Re-download the message or see 'Info' for more details")
|
||||
);
|
||||
|
||||
let alice_sent_msg = alice
|
||||
.send_text(alice_chat_id, "Hi all, it's Alice introducing Fiona")
|
||||
.await;
|
||||
bob.recv_msg(&alice_sent_msg).await;
|
||||
|
||||
// Now Bob has Fiona's key and can verify the message.
|
||||
// The message is by non-verified member,
|
||||
// but the checks have been removed
|
||||
// and the message should be downloaded as usual.
|
||||
let bob_msg = bob.recv_msg(&fiona_sent_msg).await;
|
||||
assert_eq!(bob_msg.download_state, DownloadState::Done);
|
||||
assert_eq!(bob_msg.text, "Hi");
|
||||
|
||||
Reference in New Issue
Block a user