@@ -5,7 +5,6 @@ use std::collections::HashSet;
5
5
use std:: path:: { Path , PathBuf } ;
6
6
use std:: str;
7
7
8
- use anyhow:: bail;
9
8
use anyhow:: { Context as _, Result , ensure, format_err} ;
10
9
use deltachat_contact_tools:: { VcardContact , parse_vcard} ;
11
10
use deltachat_derive:: { FromSql , ToSql } ;
@@ -1795,7 +1794,9 @@ pub async fn delete_msgs_ex(
1795
1794
"Cannot request deletion of unencrypted message for others"
1796
1795
) ;
1797
1796
1798
- deleted_info_msgs. extend ( get_webxdc_info_messages ( context, & msg) . await ?) ;
1797
+ if msg. viewtype == Viewtype :: Webxdc {
1798
+ deleted_info_msgs. extend ( get_webxdc_info_messages ( context, & msg) . await ?) ;
1799
+ }
1799
1800
modified_chat_ids. insert ( msg. chat_id ) ;
1800
1801
deleted_rfc724_mid. push ( msg. rfc724_mid . clone ( ) ) ;
1801
1802
@@ -1815,31 +1816,17 @@ pub async fn delete_msgs_ex(
1815
1816
}
1816
1817
}
1817
1818
res?;
1818
-
1819
- if !deleted_info_msgs. is_empty ( ) {
1820
- if modified_chat_ids. len ( ) > 1 {
1821
- bail ! ( "Can only delete from same chat." ) ;
1822
- }
1823
- let ( info_msg_ids, info_msg_rfc724) : ( Vec < _ > , Vec < _ > ) =
1824
- deleted_info_msgs. into_iter ( ) . unzip ( ) ;
1825
-
1826
- for & msg_id in & info_msg_ids {
1827
- let msg = Message :: load_from_db ( context, msg_id) . await ?;
1828
- delete_msg_locally ( context, & msg) . await ?;
1829
- }
1830
-
1831
- if let Some ( chat_id) = modified_chat_ids. iter ( ) . next ( ) {
1832
- send_delete_request ( context, chat_id, & info_msg_rfc724) . await ?;
1833
- }
1834
- }
1819
+ let ( info_msg_ids, mut info_msg_rfc724) : ( Vec < _ > , Vec < _ > ) =
1820
+ deleted_info_msgs. into_iter ( ) . unzip ( ) ;
1835
1821
1836
1822
if delete_for_all {
1837
1823
ensure ! (
1838
1824
modified_chat_ids. len( ) == 1 ,
1839
1825
"Can delete only from same chat."
1840
1826
) ;
1841
1827
if let Some ( chat_id) = modified_chat_ids. iter ( ) . next ( ) {
1842
- send_delete_request ( context, chat_id, & deleted_rfc724_mid) . await ?;
1828
+ info_msg_rfc724. extend ( deleted_rfc724_mid) ;
1829
+ send_delete_request ( context, chat_id, & info_msg_rfc724) . await ?;
1843
1830
}
1844
1831
} else {
1845
1832
context
@@ -1849,6 +1836,11 @@ pub async fn delete_msgs_ex(
1849
1836
. await ?;
1850
1837
}
1851
1838
1839
+ for & msg_id in & info_msg_ids {
1840
+ let msg = Message :: load_from_db ( context, msg_id) . await ?;
1841
+ delete_msg_locally ( context, & msg) . await ?;
1842
+ }
1843
+
1852
1844
for & msg_id in msg_ids {
1853
1845
let msg = Message :: load_from_db ( context, msg_id) . await ?;
1854
1846
delete_msg_locally ( context, & msg) . await ?;
@@ -1867,6 +1859,10 @@ async fn send_delete_request(
1867
1859
deleted_rfc724_mid : & [ String ] ,
1868
1860
) -> Result < MsgId > {
1869
1861
let mut msg = Message :: new_text ( "🚮" . to_owned ( ) ) ;
1862
+ // We don't want to send deletion requests in chats w/o encryption:
1863
+ // - These are usually chats with non-DC clients who won't respect deletion requests
1864
+ // anyway and display a weird trash bin message instead.
1865
+ // - Deletion of world-visible unencrypted messages seems not very useful.
1870
1866
msg. param . set_int ( Param :: GuaranteeE2ee , 1 ) ;
1871
1867
msg. param
1872
1868
. set ( Param :: DeleteRequestFor , deleted_rfc724_mid. join ( " " ) ) ;
0 commit comments