mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 01:16:31 +03:00
test: Deletion request fails in an unencrypted chat and the message remains
This commit is contained in:
@@ -3885,3 +3885,20 @@ async fn test_send_delete_request() -> Result<()> {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
|
async fn test_send_delete_request_no_encryption() -> Result<()> {
|
||||||
|
let mut tcm = TestContextManager::new();
|
||||||
|
let alice = &tcm.alice().await;
|
||||||
|
let bob = &tcm.bob().await;
|
||||||
|
let alice_chat = alice.create_email_chat(bob).await;
|
||||||
|
|
||||||
|
// Alice sends a message, then tries to send a deletion request which fails.
|
||||||
|
let sent1 = alice.send_text(alice_chat.id, "wtf").await;
|
||||||
|
assert!(message::delete_msgs_ex(alice, &[sent1.sender_msg_id], true)
|
||||||
|
.await
|
||||||
|
.is_err());
|
||||||
|
sent1.load_from_db().await;
|
||||||
|
assert_eq!(alice_chat.id.get_msg_cnt(alice).await?, 1);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|||||||
@@ -1760,6 +1760,10 @@ pub async fn delete_msgs_ex(
|
|||||||
);
|
);
|
||||||
if let Some(chat_id) = modified_chat_ids.iter().next() {
|
if let Some(chat_id) = modified_chat_ids.iter().next() {
|
||||||
let mut msg = Message::new_text("🚮".to_owned());
|
let mut msg = Message::new_text("🚮".to_owned());
|
||||||
|
// We don't want to send deletion requests in chats w/o encryption:
|
||||||
|
// - These are usually chats with non-DC clients who won't respect deletion requests
|
||||||
|
// anyway and display a weird trash bin message instead.
|
||||||
|
// - Deletion of world-visible unencrypted messages seems not very useful.
|
||||||
msg.param.set_int(Param::GuaranteeE2ee, 1);
|
msg.param.set_int(Param::GuaranteeE2ee, 1);
|
||||||
msg.param
|
msg.param
|
||||||
.set(Param::DeleteRequestFor, deleted_rfc724_mid.join(" "));
|
.set(Param::DeleteRequestFor, deleted_rfc724_mid.join(" "));
|
||||||
|
|||||||
@@ -1531,6 +1531,8 @@ async fn add_parts(
|
|||||||
} else if let Some(rfc724_mid_list) = mime_parser.get_header(HeaderDef::ChatDelete) {
|
} else if let Some(rfc724_mid_list) = mime_parser.get_header(HeaderDef::ChatDelete) {
|
||||||
chat_id = DC_CHAT_ID_TRASH;
|
chat_id = DC_CHAT_ID_TRASH;
|
||||||
if let Some(part) = mime_parser.parts.first() {
|
if let Some(part) = mime_parser.parts.first() {
|
||||||
|
// See `message::delete_msgs_ex()`, unlike edit requests, DC doesn't send unencrypted
|
||||||
|
// deletion requests, so there's no need to support them.
|
||||||
if part.param.get_bool(Param::GuaranteeE2ee).unwrap_or(false) {
|
if part.param.get_bool(Param::GuaranteeE2ee).unwrap_or(false) {
|
||||||
let mut modified_chat_ids = HashSet::new();
|
let mut modified_chat_ids = HashSet::new();
|
||||||
let mut msg_ids = Vec::new();
|
let mut msg_ids = Vec::new();
|
||||||
|
|||||||
Reference in New Issue
Block a user