Skip to content

Commit 84fd32a

Browse files
SeptiasHocuri
andcommitted
fixes
co-authored-by: Hocuri <[email protected]>
1 parent 9dd8426 commit 84fd32a

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

src/message.rs

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use std::collections::HashSet;
55
use std::path::{Path, PathBuf};
66
use std::str;
77

8-
use anyhow::bail;
98
use anyhow::{Context as _, Result, ensure, format_err};
109
use deltachat_contact_tools::{VcardContact, parse_vcard};
1110
use deltachat_derive::{FromSql, ToSql};
@@ -1795,7 +1794,9 @@ pub async fn delete_msgs_ex(
17951794
"Cannot request deletion of unencrypted message for others"
17961795
);
17971796

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+
}
17991800
modified_chat_ids.insert(msg.chat_id);
18001801
deleted_rfc724_mid.push(msg.rfc724_mid.clone());
18011802

@@ -1815,31 +1816,17 @@ pub async fn delete_msgs_ex(
18151816
}
18161817
}
18171818
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();
18351821

18361822
if delete_for_all {
18371823
ensure!(
18381824
modified_chat_ids.len() == 1,
18391825
"Can delete only from same chat."
18401826
);
18411827
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?;
18431830
}
18441831
} else {
18451832
context
@@ -1849,6 +1836,11 @@ pub async fn delete_msgs_ex(
18491836
.await?;
18501837
}
18511838

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+
18521844
for &msg_id in msg_ids {
18531845
let msg = Message::load_from_db(context, msg_id).await?;
18541846
delete_msg_locally(context, &msg).await?;
@@ -1867,6 +1859,10 @@ async fn send_delete_request(
18671859
deleted_rfc724_mid: &[String],
18681860
) -> Result<MsgId> {
18691861
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.
18701866
msg.param.set_int(Param::GuaranteeE2ee, 1);
18711867
msg.param
18721868
.set(Param::DeleteRequestFor, deleted_rfc724_mid.join(" "));

0 commit comments

Comments
 (0)