mirror of
https://github.com/chatmail/core.git
synced 2026-04-29 11:26:29 +03:00
feat: Preserve minimum info for trashed messages
+ Make `MsgId::trash()` `pub(crate)`, not public. + In `delete_expired_messages()`, prepare SQL statements to be executed in a loop.
This commit is contained in:
@@ -125,27 +125,16 @@ impl MsgId {
|
||||
/// if all parts of the message are trashed with this flag. `true` if the user explicitly
|
||||
/// deletes the message. As for trashing a partially downloaded message when replacing it with
|
||||
/// a fully downloaded one, see `receive_imf::add_parts()`.
|
||||
pub async fn trash(self, context: &Context, on_server: bool) -> Result<()> {
|
||||
let chat_id = DC_CHAT_ID_TRASH;
|
||||
let deleted_subst = match on_server {
|
||||
true => ", deleted=1",
|
||||
false => "",
|
||||
};
|
||||
pub(crate) async fn trash(self, context: &Context, on_server: bool) -> Result<()> {
|
||||
context
|
||||
.sql
|
||||
.execute(
|
||||
// If you change which information is removed here, also change delete_expired_messages() and
|
||||
// which information receive_imf::add_parts() still adds to the db if the chat_id is TRASH
|
||||
&format!(
|
||||
"UPDATE msgs SET \
|
||||
chat_id=?, txt='', txt_normalized=NULL, \
|
||||
subject='', txt_raw='', \
|
||||
mime_headers='', \
|
||||
from_id=0, to_id=0, \
|
||||
param=''{deleted_subst} \
|
||||
WHERE id=?"
|
||||
),
|
||||
(chat_id, self),
|
||||
// If you change which information is preserved here, also change
|
||||
// `delete_expired_messages()` and which information `receive_imf::add_parts()`
|
||||
// still adds to the db if chat_id is TRASH.
|
||||
"INSERT OR REPLACE INTO msgs (id, rfc724_mid, timestamp, chat_id, deleted)
|
||||
SELECT ?1, rfc724_mid, timestamp, ?, ? FROM msgs WHERE id=?1",
|
||||
(self, DC_CHAT_ID_TRASH, on_server),
|
||||
)
|
||||
.await?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user