mirror of
https://github.com/chatmail/core.git
synced 2026-04-20 23:16:30 +03:00
fix: Fix info-message orderings of verified 1:1 chats (#4545)
Correctly handle messages with old timestamps for verified chats:
* They must not be sorted over a protection-changed info message
* If they change the protection, then they must not be sorted over existing other messages, because then the protection-changed info message would also be above these existing messages.
This PR fixes this:
1. Even seen messages can't be sorted into already-noticed messages anymore. **This also changes DC's behavior in the absence of verified 1:1 chats**. Before this PR, messages that are marked as seen when they are downloaded will always be sorted by their timestamp, even if it's very old.
2. protection-changed info messages are always sorted to the bottom.
**Edit:**
3. There is an exception to rule 1: Outgoing messages are still allowed to be sorted purely by their timestamp, and don't influence old messages. This is to the problem described at [*].
Together, these rules also make sure that the protection-changed info message is always right above the message causing the change.
[*] If we receive messages from two different folders, e.g. `Sent` and `Inbox`, then this will lead to wrong message ordering in many cases. I need to think about this more, or maybe someone else has an idea. One new idea that came to my mind is:
* Always sort noticed messages under the newest info message (this PR sorts them under the newest noticed message, master sorts them purely by their sent timestamp)
* Always sort unnoticed messages under the newest noticed message (that's the same behavior as in this PR and on master)
* Always sort protection-changed info messages to the bottom (as in this PR)
However, after a talk with @link2xt we instead decided to add rule 3. (see above) because it seemed a little bit easier.
This commit is contained in:
6
test-data/golden/test_old_message_1
Normal file
6
test-data/golden/test_old_message_1
Normal file
@@ -0,0 +1,6 @@
|
||||
Single#Chat#10: Bob [bob@example.net]
|
||||
--------------------------------------------------------------------------------
|
||||
Msg#10: info (Contact#Contact#Info): Messages are guaranteed to be end-to-end encrypted from now on. [NOTICED][INFO 🛡️]
|
||||
Msg#11: info (Contact#Contact#Info): Bob sent a message from another device. [NOTICED][INFO 🛡️❌]
|
||||
Msg#12: (Contact#Contact#10): Message from Thunderbird [SEEN]
|
||||
--------------------------------------------------------------------------------
|
||||
7
test-data/golden/test_old_message_2
Normal file
7
test-data/golden/test_old_message_2
Normal file
@@ -0,0 +1,7 @@
|
||||
Single#Chat#10: Bob [bob@example.net]
|
||||
--------------------------------------------------------------------------------
|
||||
Msg#10: info (Contact#Contact#Info): Messages are guaranteed to be end-to-end encrypted from now on. [NOTICED][INFO 🛡️]
|
||||
Msg#11: info (Contact#Contact#Info): Bob sent a message from another device. [NOTICED][INFO 🛡️❌]
|
||||
Msg#12: (Contact#Contact#10): Somewhat old message [FRESH]
|
||||
Msg#13: (Contact#Contact#10): Even older message, that must NOT be shown before the info message [SEEN]
|
||||
--------------------------------------------------------------------------------
|
||||
7
test-data/golden/test_old_message_3
Normal file
7
test-data/golden/test_old_message_3
Normal file
@@ -0,0 +1,7 @@
|
||||
Single#Chat#10: Bob [bob@example.net]
|
||||
--------------------------------------------------------------------------------
|
||||
Msg#10: info (Contact#Contact#Info): Messages are guaranteed to be end-to-end encrypted from now on. [NOTICED][INFO 🛡️]
|
||||
Msg#11🔒: (Contact#Contact#10): Heyho from my verified device! [FRESH]
|
||||
Msg#12: info (Contact#Contact#Info): Bob sent a message from another device. [NOTICED][INFO 🛡️❌]
|
||||
Msg#13: (Contact#Contact#10): Old, unverified message [SEEN]
|
||||
--------------------------------------------------------------------------------
|
||||
Reference in New Issue
Block a user