Skip to content

Commit c8ef822

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 c8ef822

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

src/receive_imf.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,25 +1010,24 @@ 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(
10211021
"
10221022
UPDATE msgs SET state=? WHERE
1023-
state=? AND
1024-
hidden=0 AND
1025-
chat_id=? AND
1026-
timestamp<?",
1023+
state=?2 AND hidden=0 AND chat_id=?3 AND timestamp<?4 OR
1024+
state=?2 AND hidden=0 AND chat_id=?3 AND timestamp=?4 AND id<?5",
10271025
(
10281026
MessageState::InNoticed,
10291027
MessageState::InFresh,
10301028
chat_id,
10311029
timestamp_sort,
1030+
msg_id,
10321031
),
10331032
)
10341033
.await

0 commit comments

Comments
 (0)