diff --git a/src/chat.rs b/src/chat.rs index 33c00e9cb..5a6ca0b6f 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -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(()) } diff --git a/src/chat/chat_tests.rs b/src/chat/chat_tests.rs index 485d88491..681c2b2fb 100644 --- a/src/chat/chat_tests.rs +++ b/src/chat/chat_tests.rs @@ -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(()) }