diff --git a/src/chat.rs b/src/chat.rs index c3faadff3..a74fe9c77 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -784,6 +784,7 @@ impl ChatId { ); let chat = Chat::load_from_db(context, self).await?; + let delete_msgs_target = context.get_delete_msgs_target().await?; let sync_id = match sync { Nosync => None, Sync => chat.get_sync_id(context).await?, @@ -792,6 +793,14 @@ impl ChatId { context .sql .transaction(|transaction| { + transaction.execute( + "UPDATE imap SET target=? WHERE rfc724_mid IN (SELECT rfc724_mid FROM msgs WHERE chat_id=?)", + (delete_msgs_target, self,), + )?; + transaction.execute( + "DELETE FROM smtp WHERE msg_id IN (SELECT id FROM msgs WHERE chat_id=?)", + (self,), + )?; transaction.execute( "DELETE FROM msgs_mdns WHERE msg_id IN (SELECT id FROM msgs WHERE chat_id=?)", (self,),