From e923983dca8911ed707efbc08db084ed1260b871 Mon Sep 17 00:00:00 2001 From: iequidoo Date: Fri, 3 Nov 2023 02:22:42 -0300 Subject: [PATCH] fix: Synchronise self-chat It just didn't work before, sync messages were not generated. --- src/chat.rs | 2 +- src/sync.rs | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/chat.rs b/src/chat.rs index 35d03b836e..f87f90cd02 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -1877,7 +1877,7 @@ impl Chat { Chattype::Single => { let mut r = None; for contact_id in get_chat_contacts(context, self.id).await? { - if contact_id == ContactId::SELF { + if contact_id == ContactId::SELF && !self.is_self_talk() { continue; } if r.is_some() { diff --git a/src/sync.rs b/src/sync.rs index a078e42d88..778bac275c 100644 --- a/src/sync.rs +++ b/src/sync.rs @@ -615,17 +615,23 @@ mod tests { sync(&alices).await?; assert!(!alices[1].add_or_lookup_contact(&bob).await.is_blocked()); + // Test syncing of chat visibility on a self-chat. This way we test: + // - Self-chat synchronisation. + // - That sync messages don't unarchive the self-chat. + let a0self_chat_id = alices[0].get_self_chat().await.id; assert_eq!( - alices[1].get_chat(&bob).await.get_visibility(), + alices[1].get_self_chat().await.get_visibility(), ChatVisibility::Normal ); let mut visibilities = ChatVisibility::iter().chain(std::iter::once(ChatVisibility::Normal)); visibilities.next(); for v in visibilities { - a0b_chat_id.set_visibility(&alices[0], v).await?; + a0self_chat_id.set_visibility(&alices[0], v).await?; sync(&alices).await?; - assert_eq!(alices[1].get_chat(&bob).await.get_visibility(), v); + for a in &alices { + assert_eq!(a.get_self_chat().await.get_visibility(), v); + } } use chat::MuteDuration;