Skip to content

Commit

Permalink
fix: Synchronise self-chat
Browse files Browse the repository at this point in the history
It just didn't work before, sync messages were not generated.
  • Loading branch information
iequidoo committed Nov 4, 2023
1 parent f475386 commit e923983
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
12 changes: 9 additions & 3 deletions src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e923983

Please sign in to comment.