From ea87c78d349d313ade9fb11f210b23a759feaa98 Mon Sep 17 00:00:00 2001 From: link2xt Date: Wed, 29 Mar 2023 23:48:17 +0000 Subject: [PATCH] Do not return media from trashed messages in the "All media" view. --- CHANGELOG.md | 4 ++++ src/chat.rs | 20 +++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 45af4ed94e..3f295d13ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ - transfer backup: Connect to mutliple provider addresses concurrently. This should speed up connection time significantly on the getter side. #4240 - Make sure BackupProvider is cancelled on drop (or dc_backup_provider_unref). The BackupProvider will now alaway finish with an IMEX event of 1000 or 0, previoulsy it would sometimes finishe with 1000 (success) when it really was 0 (failure). #4242 +### Fixes +- Do not return media from trashed messages in the "All media" view. #4247 + + ## [1.112.1] - 2023-03-27 ### Changes diff --git a/src/chat.rs b/src/chat.rs index eaffb476ff..b74f31c135 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -2727,12 +2727,14 @@ pub async fn get_chat_media( "SELECT id FROM msgs WHERE (1=? OR chat_id=?) + AND chat_id != ? AND (type=? OR type=? OR type=?) AND hidden=0 ORDER BY timestamp, id;", paramsv![ chat_id.is_none(), chat_id.unwrap_or_else(|| ChatId::new(0)), + DC_CHAT_ID_TRASH, msg_type, if msg_type2 != Viewtype::Unknown { msg_type2 @@ -3795,6 +3797,7 @@ mod tests { use crate::chatlist::{get_archived_cnt, Chatlist}; use crate::constants::{DC_GCL_ARCHIVED_ONLY, DC_GCL_NO_SPECIALS}; use crate::contact::{Contact, ContactAddress}; + use crate::message::delete_msgs; use crate::receive_imf::receive_imf; use crate::test_utils::TestContext; @@ -5977,7 +5980,7 @@ mod tests { include_bytes!("../test-data/image/avatar64x64.png"), ) .await?; - send_media( + let second_image_msg_id = send_media( &t, chat_id2, Viewtype::Image, @@ -6079,6 +6082,21 @@ mod tests { 4 ); + // Delete an image. + delete_msgs(&t, &[second_image_msg_id]).await?; + assert_eq!( + get_chat_media( + &t, + None, + Viewtype::Image, + Viewtype::Sticker, + Viewtype::Webxdc, + ) + .await? + .len(), + 3 + ); + Ok(()) } }