Skip to content

Commit 8435f40

Browse files
committed
fix: don't create tombstones when synchronizing broadcast list members
1 parent 49a0b2d commit 8435f40

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/chat.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4722,7 +4722,21 @@ async fn set_contacts_by_addrs(context: &Context, id: ChatId, addrs: &[String])
47224722
if contacts == contacts_old {
47234723
return Ok(());
47244724
}
4725-
update_chat_contacts_table(context, time(), id, &contacts).await?;
4725+
context
4726+
.sql
4727+
.transaction(move |transaction| {
4728+
transaction.execute("DELETE FROM chats_contacts WHERE chat_id=?", (id,))?;
4729+
4730+
// We do not care about `add_timestamp` column
4731+
// because timestamps are not used for broadcast lists.
4732+
let mut statement = transaction
4733+
.prepare("INSERT INTO chats_contacts (chat_id, contact_id) VALUES (?, ?)")?;
4734+
for contact_id in &contacts {
4735+
statement.execute((id, contact_id))?;
4736+
}
4737+
Ok(())
4738+
})
4739+
.await?;
47264740
context.emit_event(EventType::ChatModified(id));
47274741
Ok(())
47284742
}

src/chat/chat_tests.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3125,6 +3125,9 @@ async fn test_sync_broadcast() -> Result<()> {
31253125
remove_contact_from_chat(alice0, a0_broadcast_id, a0b_contact_id).await?;
31263126
sync(alice0, alice1).await;
31273127
assert!(get_chat_contacts(alice1, a1_broadcast_id).await?.is_empty());
3128+
assert!(get_past_chat_contacts(alice1, a1_broadcast_id)
3129+
.await?
3130+
.is_empty());
31283131
Ok(())
31293132
}
31303133

0 commit comments

Comments
 (0)