fix: Don't mark messages added to the db later as noticed when handling self-MDN#8263
fix: Don't mark messages added to the db later as noticed when handling self-MDN#8263iequidoo wants to merge 2 commits into
Conversation
01eb460 to
7717de3
Compare
| hidden=0 AND | ||
| chat_id=? AND | ||
| (timestamp,id)<(?,?)", | ||
| timestamp<=? AND |
There was a problem hiding this comment.
Maybe we should exclude timestamp at all from this logic and assume that the user notices messages in the order of their addition on the other device, and messages arrive in the same order on devices. Otherwise the condition becomes too strict and doesn't include messages actually noticed on the other device, see line 977 above:
.and_modify(|pos| *pos = cmp::max(*pos, (msg.timestamp_sort, msg.id)))EDIT: Decided to leave filtering by timestamp to protect from multi-relay reordering and overall rely less on the server side. Also changed timestamp<=? to timestamp<? to be on the safe side. It's better if the user sees a message once more than misses it if it has the same timestamp. EDIT: The latter breaks the JSON-RPC tests, so decided to leave <= for now, it's a corner case anyway.
7717de3 to
f832f25
Compare
f832f25 to
ceb3771
Compare
…ng self-MDN The device which issued the MDN might not have these messages at that moment, so only mark messages having lower ids as noticed. Still, additionally filter messages by timestamp to protect from multi-relay message reordering and overall rely less on the server side. We assume that all clocks in the chat are synchronized. This doesn't fix the problem completely because messages may be received by devices in different order, but should fix it in most cases.
ceb3771 to
1ddda16
Compare
The device which issued the MDN might not have these messages at that moment, so only mark messages
having lower ids as noticed. Still, additionally filter messages by timestamp to protect from
multi-relay message reordering and overall rely less on the server side. We assume that all clocks
in the chat are synchronized.
This doesn't fix the problem completely because messages may be received by devices in different
order, but should fix it in most cases.
The existing condition became incorrect with ef26568.
test: Add function to queue MDN into smtpis extracted from #8008