mirror of
https://github.com/chatmail/core.git
synced 2026-04-19 14:36:29 +03:00
delete known messaes when deleting chat
This commit is contained in:
@@ -1738,16 +1738,7 @@ pub async fn delete_msgs_ex(
|
||||
modified_chat_ids.insert(msg.chat_id);
|
||||
deleted_rfc724_mid.push(msg.rfc724_mid.clone());
|
||||
|
||||
let target = context.get_delete_msgs_target().await?;
|
||||
let update_db = |trans: &mut rusqlite::Transaction| {
|
||||
trans.execute(
|
||||
"UPDATE imap SET target=? WHERE rfc724_mid=?",
|
||||
(target, msg.rfc724_mid),
|
||||
)?;
|
||||
trans.execute("DELETE FROM smtp WHERE msg_id=?", (msg_id,))?;
|
||||
Ok(())
|
||||
};
|
||||
if let Err(e) = context.sql.transaction(update_db).await {
|
||||
if let Err(e) = delete_single_msg_from_imap(context, msg).await {
|
||||
error!(context, "delete_msgs: failed to update db: {e:#}.");
|
||||
res = Err(e);
|
||||
continue;
|
||||
@@ -1788,6 +1779,20 @@ pub async fn delete_msgs_ex(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn delete_single_msg_from_imap(context: &Context, msg: Message) -> Result<()> {
|
||||
let target = context.get_delete_msgs_target().await?;
|
||||
let update_db = |trans: &mut rusqlite::Transaction| {
|
||||
trans.execute(
|
||||
"UPDATE imap SET target=? WHERE rfc724_mid=?",
|
||||
(target, msg.rfc724_mid),
|
||||
)?;
|
||||
trans.execute("DELETE FROM smtp WHERE msg_id=?", (msg.id,))?;
|
||||
Ok(())
|
||||
};
|
||||
context.sql.transaction(update_db).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Marks requested messages as seen.
|
||||
pub async fn markseen_msgs(context: &Context, msg_ids: Vec<MsgId>) -> Result<()> {
|
||||
if msg_ids.is_empty() {
|
||||
|
||||
Reference in New Issue
Block a user