Skip to content

Commit f1964c3

Browse files
committed
pass timestamp to update_chat_contacts_table
1 parent 8c1dd44 commit f1964c3

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/chat.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3588,10 +3588,10 @@ pub(crate) async fn create_broadcast_list_ex(
35883588
/// Set chat contacts in the `chats_contacts` table.
35893589
pub(crate) async fn update_chat_contacts_table(
35903590
context: &Context,
3591+
timestamp: i64,
35913592
id: ChatId,
35923593
contacts: &HashSet<ContactId>,
35933594
) -> Result<()> {
3594-
let now = time();
35953595
context
35963596
.sql
35973597
.transaction(move |transaction| {
@@ -3600,21 +3600,21 @@ pub(crate) async fn update_chat_contacts_table(
36003600
// We add members from `contacts` back below.
36013601
transaction.execute(
36023602
"UPDATE chats_contacts
3603-
SET remove_timestamp=MAX(add_timestamp+1, ?)
3604-
WHERE chat_id=?",
3605-
(now, id),
3603+
SET remove_timestamp=MAX(add_timestamp+1, ?)
3604+
WHERE chat_id=?",
3605+
(timestamp, id),
36063606
)?;
36073607

36083608
for contact_id in contacts {
36093609
// We bumped `add_timestamp` for existing rows above,
36103610
// so on conflict it is enough to set `add_timestamp = remove_timestamp`
3611-
// and this guarantees that `add_timestamp` is no less than `now`.
3611+
// and this guarantees that `add_timestamp` is no less than `timestamp`.
36123612
transaction.execute(
36133613
"INSERT INTO chats_contacts (chat_id, contact_id, add_timestamp)
36143614
VALUES (?1, ?2, ?3)
36153615
ON CONFLICT (chat_id, contact_id)
36163616
DO UPDATE SET add_timestamp=remove_timestamp",
3617-
(id, contact_id, now),
3617+
(id, contact_id, timestamp),
36183618
)?;
36193619
}
36203620
Ok(())
@@ -4578,7 +4578,7 @@ async fn set_contacts_by_addrs(context: &Context, id: ChatId, addrs: &[String])
45784578
if contacts == contacts_old {
45794579
return Ok(());
45804580
}
4581-
update_chat_contacts_table(context, id, &contacts).await?;
4581+
update_chat_contacts_table(context, time(), id, &contacts).await?;
45824582
context.emit_event(EventType::ChatModified(id));
45834583
Ok(())
45844584
}

src/receive_imf.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2387,7 +2387,13 @@ async fn apply_group_changes(
23872387
}
23882388

23892389
if new_members != chat_contacts {
2390-
chat::update_chat_contacts_table(context, chat_id, &new_members).await?;
2390+
chat::update_chat_contacts_table(
2391+
context,
2392+
mime_parser.timestamp_sent,
2393+
chat_id,
2394+
&new_members,
2395+
)
2396+
.await?;
23912397
chat_contacts = new_members;
23922398
send_event_chat_modified = true;
23932399
}

0 commit comments

Comments
 (0)