From 548fadc84aae05a4f3f91b3cd332d61c0a32375c Mon Sep 17 00:00:00 2001 From: link2xt Date: Sat, 4 Jan 2025 19:48:32 +0000 Subject: [PATCH] fix: prioritize mailing list over self-sent messages New Delta Chat is going to send self-sent messages with undisclosed recipients instead of placing self into the `To` field. To avoid assigning broadcast list messages to Saved Messages chat, we should check the mailing list headers before attempting to assign to Saved Messages. --- src/receive_imf.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/receive_imf.rs b/src/receive_imf.rs index 9fb741edc..4faf2e65c 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -1181,6 +1181,22 @@ async fn add_parts( .await?; } + if chat_id.is_none() { + // Check if the message belongs to a broadcast list. + if let Some(mailinglist_header) = mime_parser.get_mailinglist_header() { + let listid = mailinglist_header_listid(mailinglist_header)?; + chat_id = Some( + if let Some((id, ..)) = chat::get_chat_id_by_grpid(context, &listid).await? { + id + } else { + let name = + compute_mailinglist_name(mailinglist_header, &listid, mime_parser); + chat::create_broadcast_list_ex(context, Nosync, listid, name).await? + }, + ); + } + } + if chat_id.is_none() && self_sent { // from_id==to_id==ContactId::SELF - this is a self-sent messages, // maybe an Autocrypt Setup Message @@ -1200,22 +1216,6 @@ async fn add_parts( } } } - - if chat_id.is_none() { - // Check if the message belongs to a broadcast list. - if let Some(mailinglist_header) = mime_parser.get_mailinglist_header() { - let listid = mailinglist_header_listid(mailinglist_header)?; - chat_id = Some( - if let Some((id, ..)) = chat::get_chat_id_by_grpid(context, &listid).await? { - id - } else { - let name = - compute_mailinglist_name(mailinglist_header, &listid, mime_parser); - chat::create_broadcast_list_ex(context, Nosync, listid, name).await? - }, - ); - } - } } if fetching_existing_messages && mime_parser.decrypting_failed {