Skip to content

Commit ba1530b

Browse files
committed
fix: When receiving MDN, mark all preceding messages as noticed, even having same timestamp (#7928)
This fixes flaky JSON-RPC `test_multidevice_sync_seen`.
1 parent b0154b0 commit ba1530b

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/receive_imf.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,11 +1010,11 @@ UPDATE config SET value=? WHERE keyname='configured_addr' AND value!=?1
10101010
&& msg.chat_visibility == ChatVisibility::Archived;
10111011
updated_chats
10121012
.entry(msg.chat_id)
1013-
.and_modify(|ts| *ts = cmp::max(*ts, msg.timestamp_sort))
1014-
.or_insert(msg.timestamp_sort);
1013+
.and_modify(|pos| *pos = cmp::max(*pos, (msg.timestamp_sort, msg.id)))
1014+
.or_insert((msg.timestamp_sort, msg.id));
10151015
}
10161016
}
1017-
for (chat_id, timestamp_sort) in updated_chats {
1017+
for (chat_id, (timestamp_sort, msg_id)) in updated_chats {
10181018
context
10191019
.sql
10201020
.execute(
@@ -1023,12 +1023,14 @@ UPDATE msgs SET state=? WHERE
10231023
state=? AND
10241024
hidden=0 AND
10251025
chat_id=? AND
1026-
timestamp<?",
1026+
(timestamp<? OR timestamp=? AND id<?)",
10271027
(
10281028
MessageState::InNoticed,
10291029
MessageState::InFresh,
10301030
chat_id,
10311031
timestamp_sort,
1032+
timestamp_sort,
1033+
msg_id,
10321034
),
10331035
)
10341036
.await

0 commit comments

Comments
 (0)