From 49f5523b67e1e9fded01c87429dd0a32faa17434 Mon Sep 17 00:00:00 2001 From: link2xt Date: Sat, 4 Jan 2025 06:29:37 +0000 Subject: [PATCH] fix: allow empty `To` field for self-sent messages Currently Delta Chat puts self address in the To field to avoid the To field being empty. There is a plan to put empty `hidden-recipients` group there, this fix prepares the receiver for such messages. --- src/receive_imf.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/receive_imf.rs b/src/receive_imf.rs index 4faf2e65c..1003d3978 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -1039,7 +1039,11 @@ async fn add_parts( state = MessageState::OutDelivered; to_id = to_ids.first().copied().unwrap_or_default(); - let self_sent = to_ids.len() == 1 && to_ids.contains(&ContactId::SELF); + // Older Delta Chat versions with core <=1.152.2 only accepted + // self-sent messages in Saved Messages with own address in the `To` field. + // New Delta Chat versions may use empty `To` field + // with only a single `hidden-recipients` group in this case. + let self_sent = to_ids.is_empty() || (to_ids.len() == 1 && to_id == ContactId::SELF); if mime_parser.sync_items.is_some() && self_sent { chat_id = Some(DC_CHAT_ID_TRASH);