api: don't load trashed messages with Message::load_from_db

API now pretends that trashed messages don't exist.
This way callers don't have to check if loaded message
belongs to trash chat.
If message may be trashed by the time it is attempted to be loaded,
callers should use Message::load_from_db_optional.

Most changes are around receive_status_update() function
because previously it relied on loading trashed status update
messages immediately after adding them to the database.
This commit is contained in:
link2xt
2024-04-13 23:34:09 +00:00
parent 94ac2b1097
commit c069190b68
11 changed files with 161 additions and 116 deletions

View File

@@ -4014,8 +4014,7 @@ async fn test_member_left_does_not_create_chat() -> Result<()> {
// which some members simply deleted and some members left,
// recreating the chat for others.
remove_contact_from_chat(&alice, alice_chat_id, ContactId::SELF).await?;
let bob_chat_id = bob.recv_msg(&alice.pop_sent_msg().await).await.chat_id;
assert!(bob_chat_id.is_trash());
bob.recv_msg_trash(&alice.pop_sent_msg().await).await;
Ok(())
}
@@ -4365,8 +4364,8 @@ async fn test_forged_from() -> Result<()> {
.payload
.replace("bob@example.net", "notbob@example.net");
let msg = alice.recv_msg(&sent_msg).await;
assert!(msg.chat_id.is_trash());
let msg = alice.recv_msg_opt(&sent_msg).await;
assert!(msg.is_none());
Ok(())
}