From b227ff87dc0edc4d81a365c2fcac64cb94218629 Mon Sep 17 00:00:00 2001 From: iequidoo Date: Sat, 9 Sep 2023 21:48:56 -0300 Subject: [PATCH] fix: lookup_chat_by_reply(): Skip undecipherable parent messages created by older versions (#4676) It's just a dirty hack checking the error prefix, but as undecipherable messages are remembered in the db now, the hack may be removed soon. --- src/mimeparser.rs | 2 ++ src/receive_imf.rs | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/mimeparser.rs b/src/mimeparser.rs index 73952ba8b..fa5bfef92 100644 --- a/src/mimeparser.rs +++ b/src/mimeparser.rs @@ -438,6 +438,8 @@ impl MimeMessage { typ: Viewtype::Text, msg_raw: Some(txt.clone()), msg: txt, + // Don't change the error prefix for now, + // receive_imf.rs:lookup_chat_by_reply() checks it. error: Some(format!("Decrypting failed: {err:#}")), ..Default::default() }; diff --git a/src/receive_imf.rs b/src/receive_imf.rs index 2f3acc1b1..889bb1175 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -1411,7 +1411,16 @@ async fn lookup_chat_by_reply( if let Some(parent) = parent { let parent_chat = Chat::load_from_db(context, parent.chat_id).await?; - if parent.download_state != DownloadState::Done { + if parent.download_state != DownloadState::Done + // TODO (2023-09-12): Added for backward compatibility with versions that did not have + // `DownloadState::Undecipherable`. Remove eventually with the comment in + // `MimeMessage::from_bytes()`. + || parent + .error + .as_ref() + .filter(|e| e.starts_with("Decrypting failed:")) + .is_some() + { // If the parent msg is not fully downloaded or undecipherable, it may have been // assigned to the wrong chat (they often get assigned to the 1:1 chat with the sender). return Ok(None);