File tree 3 files changed +23
-0
lines changed
3 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -3885,3 +3885,20 @@ async fn test_send_delete_request() -> Result<()> {
3885
3885
3886
3886
Ok ( ( ) )
3887
3887
}
3888
+
3889
+ #[ tokio:: test( flavor = "multi_thread" , worker_threads = 2 ) ]
3890
+ async fn test_send_delete_request_no_encryption ( ) -> Result < ( ) > {
3891
+ let mut tcm = TestContextManager :: new ( ) ;
3892
+ let alice = & tcm. alice ( ) . await ;
3893
+ let bob = & tcm. bob ( ) . await ;
3894
+ let alice_chat = alice. create_email_chat ( bob) . await ;
3895
+
3896
+ // Alice sends a message, then tries to send a deletion request which fails.
3897
+ let sent1 = alice. send_text ( alice_chat. id , "wtf" ) . await ;
3898
+ assert ! ( message:: delete_msgs_ex( alice, & [ sent1. sender_msg_id] , true )
3899
+ . await
3900
+ . is_err( ) ) ;
3901
+ sent1. load_from_db ( ) . await ;
3902
+ assert_eq ! ( alice_chat. id. get_msg_cnt( alice) . await ?, 1 ) ;
3903
+ Ok ( ( ) )
3904
+ }
Original file line number Diff line number Diff line change @@ -1760,6 +1760,10 @@ pub async fn delete_msgs_ex(
1760
1760
) ;
1761
1761
if let Some ( chat_id) = modified_chat_ids. iter ( ) . next ( ) {
1762
1762
let mut msg = Message :: new_text ( "🚮" . to_owned ( ) ) ;
1763
+ // We don't want to send deletion requests in chats w/o encryption:
1764
+ // - These are usually chats with non-DC clients who won't respect deletion requests
1765
+ // anyway and display a weird trash bin message instead.
1766
+ // - Deletion of world-visible unencrypted messages seems not very useful.
1763
1767
msg. param . set_int ( Param :: GuaranteeE2ee , 1 ) ;
1764
1768
msg. param
1765
1769
. set ( Param :: DeleteRequestFor , deleted_rfc724_mid. join ( " " ) ) ;
Original file line number Diff line number Diff line change @@ -1531,6 +1531,8 @@ async fn add_parts(
1531
1531
} else if let Some ( rfc724_mid_list) = mime_parser. get_header ( HeaderDef :: ChatDelete ) {
1532
1532
chat_id = DC_CHAT_ID_TRASH ;
1533
1533
if let Some ( part) = mime_parser. parts . first ( ) {
1534
+ // See `message::delete_msgs_ex()`, unlike edit requests, DC doesn't send unencrypted
1535
+ // deletion requests, so there's no need to support them.
1534
1536
if part. param . get_bool ( Param :: GuaranteeE2ee ) . unwrap_or ( false ) {
1535
1537
let mut modified_chat_ids = HashSet :: new ( ) ;
1536
1538
let mut msg_ids = Vec :: new ( ) ;
You can’t perform that action at this time.
0 commit comments