Skip to content

Commit 921633c

Browse files
committed
feat: do not replace messages with an error on verification failure
1 parent dde07e5 commit 921633c

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
@@ -1857,25 +1857,6 @@ async fn add_parts(
18571857
None
18581858
};
18591859

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

18811862
let sort_timestamp = tweak_sort_timestamp(
@@ -2133,10 +2114,6 @@ RETURNING id
21332114
DownloadState::Available
21342115
} else if mime_parser.decrypting_failed {
21352116
DownloadState::Undecipherable
2136-
} else if verification_failed {
2137-
// Verification can fail because of message reordering. Re-downloading the
2138-
// message should help if so.
2139-
DownloadState::Available
21402117
} else {
21412118
DownloadState::Done
21422119
},

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)