From bfc8c9ea1fde0fb617f09d8e7208d2c6dc8db10e Mon Sep 17 00:00:00 2001 From: iequidoo Date: Sun, 15 Dec 2024 13:21:52 -0300 Subject: [PATCH] refactor: receive_imf: Check for better_msg emptiness before per-part loop Empty `better_msg` is returned from `apply_group_changes()` when a group member addition/removal message has no effect. It's not clear why `better_msg` was checked and `chat_id` set to `DC_CHAT_ID_TRASH` in the per-part loop. --- src/receive_imf.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/receive_imf.rs b/src/receive_imf.rs index 439731e9b5..effc006358 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -1449,6 +1449,12 @@ async fn add_parts( .await?; } + // Empty `better_msg` is returned from `apply_group_changes()` when a group member + // addition/removal message has no effect. + if better_msg == Some(String::new()) && is_partial_download.is_none() { + chat_id = DC_CHAT_ID_TRASH; + } + if let Some(node_addr) = mime_parser.get_header(HeaderDef::IrohNodeAddr) { chat_id = DC_CHAT_ID_TRASH; match mime_parser.get_header(HeaderDef::InReplyTo) { @@ -1514,9 +1520,6 @@ async fn add_parts( let mut txt_raw = "".to_string(); let (msg, typ): (&str, Viewtype) = if let Some(better_msg) = &better_msg { - if better_msg.is_empty() && is_partial_download.is_none() { - chat_id = DC_CHAT_ID_TRASH; - } (better_msg, Viewtype::Text) } else { (&part.msg, part.typ)