Skip to content

Commit 70c3a75

Browse files
committed
feat: do not replace messages with an error on verification failure
1 parent 9d9e444 commit 70c3a75

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
@@ -1593,15 +1593,6 @@ impl MimeMessage {
15931593
}
15941594
}
15951595

1596-
pub fn replace_msg_by_error(&mut self, error_msg: &str) {
1597-
self.is_system_message = SystemMessage::Unknown;
1598-
if let Some(part) = self.parts.first_mut() {
1599-
part.typ = Viewtype::Text;
1600-
part.msg = format!("[{error_msg}]");
1601-
self.parts.truncate(1);
1602-
}
1603-
}
1604-
16051596
pub(crate) fn get_rfc724_mid(&self) -> Option<String> {
16061597
self.get_header(HeaderDef::MessageId)
16071598
.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
@@ -1864,25 +1864,6 @@ async fn add_parts(
18641864
None
18651865
};
18661866

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

18881869
let sort_timestamp = tweak_sort_timestamp(
@@ -2156,10 +2137,6 @@ RETURNING id
21562137
DownloadState::Available
21572138
} else if mime_parser.decrypting_failed {
21582139
DownloadState::Undecipherable
2159-
} else if verification_failed {
2160-
// Verification can fail because of message reordering. Re-downloading the
2161-
// message should help if so.
2162-
DownloadState::Available
21632140
} else {
21642141
DownloadState::Done
21652142
},

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)