mirror of
https://github.com/chatmail/core.git
synced 2026-05-04 22:06:29 +03:00
fix: don't create tombstones when synchronizing broadcast list members
This commit is contained in:
16
src/chat.rs
16
src/chat.rs
@@ -4722,7 +4722,21 @@ async fn set_contacts_by_addrs(context: &Context, id: ChatId, addrs: &[String])
|
|||||||
if contacts == contacts_old {
|
if contacts == contacts_old {
|
||||||
return Ok(());
|
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));
|
context.emit_event(EventType::ChatModified(id));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3125,6 +3125,9 @@ async fn test_sync_broadcast() -> Result<()> {
|
|||||||
remove_contact_from_chat(alice0, a0_broadcast_id, a0b_contact_id).await?;
|
remove_contact_from_chat(alice0, a0_broadcast_id, a0b_contact_id).await?;
|
||||||
sync(alice0, alice1).await;
|
sync(alice0, alice1).await;
|
||||||
assert!(get_chat_contacts(alice1, a1_broadcast_id).await?.is_empty());
|
assert!(get_chat_contacts(alice1, a1_broadcast_id).await?.is_empty());
|
||||||
|
assert!(get_past_chat_contacts(alice1, a1_broadcast_id)
|
||||||
|
.await?
|
||||||
|
.is_empty());
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user