Skip to content

Commit 04eda07

Browse files
committed
feat: do not replace messages with an error on verification failure
1 parent b53921b commit 04eda07

File tree

3 files changed

+3
-47
lines changed

3 files changed

+3
-47
lines changed

src/mimeparser.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,15 +1582,6 @@ impl MimeMessage {
15821582
}
15831583
}
15841584

1585-
pub fn replace_msg_by_error(&mut self, error_msg: &str) {
1586-
self.is_system_message = SystemMessage::Unknown;
1587-
if let Some(part) = self.parts.first_mut() {
1588-
part.typ = Viewtype::Text;
1589-
part.msg = format!("[{error_msg}]");
1590-
self.parts.truncate(1);
1591-
}
1592-
}
1593-
15941585
pub(crate) fn get_rfc724_mid(&self) -> Option<String> {
15951586
self.get_header(HeaderDef::MessageId)
15961587
.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 & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5133,21 +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-
let alice_sent_msg = alice
5146-
.send_text(alice_chat_id, "Hi all, it's Alice introducing Fiona")
5147-
.await;
5148-
bob.recv_msg(&alice_sent_msg).await;
5149-
5150-
// 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.
51515139
let bob_msg = bob.recv_msg(&fiona_sent_msg).await;
51525140
assert_eq!(bob_msg.download_state, DownloadState::Done);
51535141
assert_eq!(bob_msg.text, "Hi");

0 commit comments

Comments
 (0)