fix: don't create tombstones when synchronizing broadcast list members

This commit is contained in:
link2xt
2025-01-22 18:46:11 +00:00
committed by l
parent 49a0b2d948
commit 8435f40dae
2 changed files with 18 additions and 1 deletions

View File

@@ -4722,7 +4722,21 @@ async fn set_contacts_by_addrs(context: &Context, id: ChatId, addrs: &[String])
if contacts == contacts_old {
return Ok(());
}
update_chat_contacts_table(context, time(), id, &contacts).await?;
context
.sql
.transaction(move |transaction| {
transaction.execute("DELETE FROM chats_contacts WHERE chat_id=?", (id,))?;
// We do not care about `add_timestamp` column
// because timestamps are not used for broadcast lists.
let mut statement = transaction
.prepare("INSERT INTO chats_contacts (chat_id, contact_id) VALUES (?, ?)")?;
for contact_id in &contacts {
statement.execute((id, contact_id))?;
}
Ok(())
})
.await?;
context.emit_event(EventType::ChatModified(id));
Ok(())
}

View File

@@ -3125,6 +3125,9 @@ async fn test_sync_broadcast() -> Result<()> {
remove_contact_from_chat(alice0, a0_broadcast_id, a0b_contact_id).await?;
sync(alice0, alice1).await;
assert!(get_chat_contacts(alice1, a1_broadcast_id).await?.is_empty());
assert!(get_past_chat_contacts(alice1, a1_broadcast_id)
.await?
.is_empty());
Ok(())
}