From fba6e885ae25682ff58795b8168c95245b8a43d8 Mon Sep 17 00:00:00 2001 From: Hocuri Date: Mon, 21 Jul 2025 17:32:46 +0200 Subject: [PATCH] More multidevice fixes; it's still not working completely --- src/chat/chat_tests.rs | 4 +++- src/mimefactory.rs | 1 - src/receive_imf.rs | 18 ++++++++++-------- src/tools.rs | 1 + 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/chat/chat_tests.rs b/src/chat/chat_tests.rs index 214a2da28..2a15f20c6 100644 --- a/src/chat/chat_tests.rs +++ b/src/chat/chat_tests.rs @@ -3785,7 +3785,9 @@ async fn test_sync_broadcast() -> Result<()> { assert_eq!(a1_broadcast_chat.get_name(), a0_broadcast_chat.get_name()); assert!(get_chat_contacts(alice1, a1_broadcast_id).await?.is_empty()); add_contact_to_chat(alice0, a0_broadcast_id, a0b_contact_id).await?; - sync(alice0, alice1).await; + let sent = alice0.pop_sent_msg().await; + let rcvd = alice1.recv_msg(&sent).await; + dbg!(rcvd); // TODO // This also imports Bob's key from the vCard. // Otherwise it is possible that second device diff --git a/src/mimefactory.rs b/src/mimefactory.rs index b58efc9a2..7980d3b20 100644 --- a/src/mimefactory.rs +++ b/src/mimefactory.rs @@ -1404,7 +1404,6 @@ impl MimeFactory { } } SystemMessage::MemberAddedToGroup => { - ensure!(chat.typ != Chattype::OutBroadcast); // TODO: lookup the contact by ID rather than email address. // We are adding key-contacts, the cannot be looked up by address. let email_to_add = msg.param.get(Param::Arg).unwrap_or_default(); diff --git a/src/receive_imf.rs b/src/receive_imf.rs index 33fa7f5cb..6e29a81df 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -3482,15 +3482,17 @@ async fn apply_out_broadcast_changes( .await?; if let Some(_removed_addr) = mime_parser.get_header(HeaderDef::ChatGroupMemberRemoved) { - // The sender of the message left the broadcast channel - remove_from_chat_contacts_table(context, chat.id, from_id).await?; + if from_id != ContactId::SELF { + // The sender of the message left the broadcast channel + remove_from_chat_contacts_table(context, chat.id, from_id).await?; - return Ok(GroupChangesInfo { - better_msg: Some("".to_string()), - added_removed_id: None, - silent: true, - extra_msgs: vec![], - }); + return Ok(GroupChangesInfo { + better_msg: Some("".to_string()), + added_removed_id: None, + silent: true, + extra_msgs: vec![], + }); + } } if send_event_chat_modified { diff --git a/src/tools.rs b/src/tools.rs index 1c0e456ff..2122e02a1 100644 --- a/src/tools.rs +++ b/src/tools.rs @@ -306,6 +306,7 @@ pub(crate) fn create_id() -> String { /// and is returned as 64 Base64 characters, each containing 6 bits of entropy. /// 384 is chosen because it is sufficiently secure /// (larger than AES-128 keys used for message encryption) +/// TODO: Is it still true that we use AES-128? This info is taken from create_id() comment above. /// and divides both by 8 (byte size) and 6 (number of bits in a single Base64 character). // TODO ask someone what a good size would be here pub(crate) fn create_broadcast_shared_secret() -> String {