From 02b90a3956f50eb82cde8ff88cb53872d59c772d Mon Sep 17 00:00:00 2001 From: iequidoo Date: Fri, 19 Dec 2025 00:27:59 -0300 Subject: [PATCH] feat: Don't scale up Origin of multiple and broadcast recipients when sending a message 84161f4202177cb8ff1e2948d80cacd32ccc796b promotes group members to `Origin::IncomingTo` when accepting it instead of `CreateChat` as before, but this changes almost nothing because it happens rarely that the user only accepts a group and writes nothing there soon. Now if a message has multiple recipients, i.e. it's a 3-or-more-member group, or if it's a broadcast message, we don't scale up its recipients to `Origin::OutgoingTo`. --- src/mimefactory.rs | 9 +++++++-- src/receive_imf/receive_imf_tests.rs | 5 +++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/mimefactory.rs b/src/mimefactory.rs index 732fff545a..9c90a7e636 100644 --- a/src/mimefactory.rs +++ b/src/mimefactory.rs @@ -411,8 +411,13 @@ impl MimeFactory { }, ) .await?; - let recipient_ids: Vec<_> = recipient_ids.into_iter().collect(); - ContactId::scaleup_origin(context, &recipient_ids, Origin::OutgoingTo).await?; + let recipient_ids: Vec<_> = recipient_ids + .into_iter() + .filter(|id| *id != ContactId::SELF) + .collect(); + if recipient_ids.len() == 1 && chat.typ != Chattype::OutBroadcast { + ContactId::scaleup_origin(context, &recipient_ids, Origin::OutgoingTo).await?; + } if !msg.is_system_message() && msg.param.get_int(Param::Reaction).unwrap_or_default() == 0 diff --git a/src/receive_imf/receive_imf_tests.rs b/src/receive_imf/receive_imf_tests.rs index 40a6eddd05..d7d4d55a3b 100644 --- a/src/receive_imf/receive_imf_tests.rs +++ b/src/receive_imf/receive_imf_tests.rs @@ -3881,6 +3881,11 @@ async fn test_group_contacts_goto_bottom() -> Result<()> { let contacts = Contact::get_all(bob, 0, None).await?; assert_eq!(contacts.len(), 2); assert_eq!(contacts[0], bob_fiona_id); + + send_text_msg(bob, bob_chat_id, "ehlo".to_string()).await?; + bob.pop_sent_msg().await; + let contacts = Contact::get_all(bob, 0, None).await?; + assert_eq!(contacts[0], bob_fiona_id); Ok(()) }