feat: Sort received outgoing message down if it's fresher than all non fresh messages

Received messages shouldn't mingle with just sent ones and appear somewhere in the middle of the
chat, so we go after the newest non fresh message.

But if a received outgoing message is older than some `InSeen` message, better sort the received
message purely by timestamp (this is an heuristic in order not to break the Gmail-like case
simulated by `verified_chats::test_old_message_4()`). We could place the received message just
before that `InSeen` message, but anyway the user may not notice it.

At least this fixes outgoing messages sorting for shared accounts where messages from other devices
should be sorted the same way as incoming ones.
This commit is contained in:
iequidoo
2024-07-24 21:14:00 -03:00
committed by iequidoo
parent f1ca689f99
commit d660f55a99
5 changed files with 68 additions and 14 deletions

View File

@@ -4811,6 +4811,36 @@ async fn test_protected_group_add_remove_member_missing_key() -> Result<()> {
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_older_message_from_2nd_device() -> Result<()> {
let mut tcm = TestContextManager::new();
let alice = &tcm.alice().await;
let chat_id = alice
.create_chat_with_contact("", "bob@example.net")
.await
.id;
alice.send_text(chat_id, "We share this account").await;
let received = receive_imf(
alice,
b"From: alice@example.org\n\
To: bob@example.net\n\
Message-ID: <1234-2-4@example.org>\n\
Date: Sat, 07 Dec 1970 19:00:26 +0000\n\
\n\
I'm Alice too\n",
true,
)
.await?
.unwrap();
alice
.golden_test_chat(
received.chat_id,
"receive_imf_older_message_from_2nd_device",
)
.await;
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_dont_create_adhoc_group_on_member_removal() -> Result<()> {
let mut tcm = TestContextManager::new();