Skip to content

Commit f450b5b

Browse files
committed
feat: do not replace messages with an error on verification failure
1 parent b03d2f4 commit f450b5b

File tree

3 files changed

+3
-49
lines changed

3 files changed

+3
-49
lines changed

src/mimeparser.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,15 +1559,6 @@ impl MimeMessage {
15591559
}
15601560
}
15611561

1562-
pub fn replace_msg_by_error(&mut self, error_msg: &str) {
1563-
self.is_system_message = SystemMessage::Unknown;
1564-
if let Some(part) = self.parts.first_mut() {
1565-
part.typ = Viewtype::Text;
1566-
part.msg = format!("[{error_msg}]");
1567-
self.parts.truncate(1);
1568-
}
1569-
}
1570-
15711562
pub(crate) fn get_rfc724_mid(&self) -> Option<String> {
15721563
self.get_header(HeaderDef::MessageId)
15731564
.and_then(|msgid| parse_message_id(msgid).ok())

src/receive_imf.rs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,25 +1860,6 @@ async fn add_parts(
18601860
None
18611861
};
18621862

1863-
let mut verification_failed = false;
1864-
if !chat_id.is_special() && is_partial_download.is_none() {
1865-
// For outgoing emails in the 1:1 chat we have an exception that
1866-
// they are allowed to be unencrypted:
1867-
// 1. They can't be an attack (they are outgoing, not incoming)
1868-
// 2. Probably the unencryptedness is just a temporary state, after all
1869-
// the user obviously still uses DC
1870-
// -> Showing info messages every time would be a lot of noise
1871-
// 3. The info messages that are shown to the user ("Your chat partner
1872-
// likely reinstalled DC" or similar) would be wrong.
1873-
if chat.is_protected() && (mime_parser.incoming || chat.typ != Chattype::Single) {
1874-
if let VerifiedEncryption::NotVerified(err) = verified_encryption {
1875-
verification_failed = true;
1876-
warn!(context, "Verification problem: {err:#}.");
1877-
let s = format!("{err}. Re-download the message or see 'Info' for more details");
1878-
mime_parser.replace_msg_by_error(&s);
1879-
}
1880-
}
1881-
}
18821863
drop(chat); // Avoid using stale `chat` object.
18831864

18841865
let sort_timestamp = tweak_sort_timestamp(
@@ -2136,10 +2117,6 @@ RETURNING id
21362117
DownloadState::Available
21372118
} else if mime_parser.decrypting_failed {
21382119
DownloadState::Undecipherable
2139-
} else if verification_failed {
2140-
// Verification can fail because of message reordering. Re-downloading the
2141-
// message should help if so.
2142-
DownloadState::Available
21432120
} else {
21442121
DownloadState::Done
21452122
},

src/receive_imf/receive_imf_tests.rs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5133,23 +5133,9 @@ async fn test_unverified_member_msg() -> Result<()> {
51335133
let fiona_chat_id = fiona.get_last_msg().await.chat_id;
51345134
let fiona_sent_msg = fiona.send_text(fiona_chat_id, "Hi").await;
51355135

5136-
// The message can't be verified, but the user can re-download it.
5137-
let bob_msg = bob.recv_msg(&fiona_sent_msg).await;
5138-
assert_eq!(bob_msg.download_state, DownloadState::Available);
5139-
assert!(
5140-
bob_msg
5141-
.text
5142-
.contains("Re-download the message or see 'Info' for more details")
5143-
);
5144-
5145-
// Shift the time by 1 week to trigger gossiping.
5146-
SystemTime::shift(Duration::from_secs(3600 * 24 * 7));
5147-
let alice_sent_msg = alice
5148-
.send_text(alice_chat_id, "Hi all, it's Alice introducing Fiona")
5149-
.await;
5150-
bob.recv_msg(&alice_sent_msg).await;
5151-
5152-
// Now Bob has Fiona's key and can verify the message.
5136+
// The message is by non-verified member,
5137+
// but the checks have been removed
5138+
// and the message should be downloaded as usual.
51535139
let bob_msg = bob.recv_msg(&fiona_sent_msg).await;
51545140
assert_eq!(bob_msg.download_state, DownloadState::Done);
51555141
assert_eq!(bob_msg.text, "Hi");

0 commit comments

Comments
 (0)