From d96b4beff1e88285ea539949eae2aac13fa88754 Mon Sep 17 00:00:00 2001 From: iequidoo Date: Sun, 9 Nov 2025 04:25:34 -0300 Subject: [PATCH] feat: Don't download group messages unconditionally There was a comment that group messages should always be downloaded to avoid inconsistent group state, but this is solved by the group consistency algo nowadays in the sense that inconsistent group state won't spread to other members if we send to the group. Moreover, encrypted messages are now always downloaded, and unencrypted chat replies too, and as for ad-hoc groups, `Config::ShowEmails` controls everything. --- src/imap.rs | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/src/imap.rs b/src/imap.rs index d6acccc51..a99c22833 100644 --- a/src/imap.rs +++ b/src/imap.rs @@ -27,7 +27,7 @@ use crate::calls::{create_fallback_ice_servers, create_ice_servers_from_metadata use crate::chat::{self, ChatId, ChatIdBlocked, add_device_msg}; use crate::chatlist_events; use crate::config::Config; -use crate::constants::{self, Blocked, Chattype, ShowEmails}; +use crate::constants::{self, Blocked, ShowEmails}; use crate::contact::{Contact, ContactId, Modifier, Origin}; use crate::context::Context; use crate::events::EventType; @@ -2229,21 +2229,6 @@ pub(crate) fn create_message_id() -> String { format!("{}{}", GENERATED_PREFIX, create_id()) } -/// Returns chat by prefetched headers. -async fn prefetch_get_chat( - context: &Context, - headers: &[mailparse::MailHeader<'_>], -) -> Result> { - let parent = get_prefetch_parent_message(context, headers).await?; - if let Some(parent) = &parent { - return Ok(Some( - chat::Chat::load_from_db(context, parent.get_chat_id()).await?, - )); - } - - Ok(None) -} - /// Determines whether the message should be downloaded based on prefetched headers. pub(crate) async fn prefetch_should_download( context: &Context, @@ -2262,14 +2247,6 @@ pub(crate) async fn prefetch_should_download( // We do not know the Message-ID or the Message-ID is missing (in this case, we create one in // the further process). - if let Some(chat) = prefetch_get_chat(context, headers).await? { - if chat.typ == Chattype::Group && !chat.id.is_special() { - // This might be a group command, like removing a group member. - // We really need to fetch this to avoid inconsistent group state. - return Ok(true); - } - } - let maybe_ndn = if let Some(from) = headers.get_header_value(HeaderDef::From_) { let from = from.to_ascii_lowercase(); from.contains("mailer-daemon") || from.contains("mail-daemon")