mirror of
https://github.com/chatmail/core.git
synced 2026-05-07 08:56:30 +03:00
Trash messages more thoroughly (#2273)
Esp. remove some information for newly-arriving messages
This commit is contained in:
@@ -954,26 +954,34 @@ async fn add_parts(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// If you change which information is skipped if the message is trashed,
|
||||||
|
// also change `MsgId::trash()` and `delete_expired_messages()`
|
||||||
|
let trash = chat_id.is_trash();
|
||||||
|
|
||||||
stmt.execute(paramsv![
|
stmt.execute(paramsv![
|
||||||
rfc724_mid,
|
rfc724_mid,
|
||||||
server_folder,
|
server_folder,
|
||||||
server_uid as i32,
|
server_uid as i32,
|
||||||
chat_id,
|
chat_id,
|
||||||
from_id as i32,
|
if trash { 0 } else { from_id as i32 },
|
||||||
to_id as i32,
|
if trash { 0 } else { to_id as i32 },
|
||||||
sort_timestamp,
|
sort_timestamp,
|
||||||
sent_timestamp,
|
sent_timestamp,
|
||||||
rcvd_timestamp,
|
rcvd_timestamp,
|
||||||
part.typ,
|
part.typ,
|
||||||
state,
|
state,
|
||||||
is_dc_message,
|
is_dc_message,
|
||||||
part.msg,
|
if trash { "" } else { &part.msg },
|
||||||
// txt_raw might contain invalid utf8
|
// txt_raw might contain invalid utf8
|
||||||
txt_raw,
|
if trash { "" } else { &txt_raw },
|
||||||
part.param.to_string(),
|
if trash {
|
||||||
|
"".to_string()
|
||||||
|
} else {
|
||||||
|
part.param.to_string()
|
||||||
|
},
|
||||||
part.bytes as isize,
|
part.bytes as isize,
|
||||||
is_hidden,
|
is_hidden,
|
||||||
if save_mime_headers || mime_modified {
|
if (save_mime_headers || mime_modified) && !trash {
|
||||||
mime_headers.clone()
|
mime_headers.clone()
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|||||||
@@ -308,8 +308,10 @@ pub(crate) async fn delete_expired_messages(context: &Context) -> Result<bool, E
|
|||||||
let mut updated = context
|
let mut updated = context
|
||||||
.sql
|
.sql
|
||||||
.execute(
|
.execute(
|
||||||
|
// If you change which information is removed here, also change MsgId::trash() and
|
||||||
|
// which information dc_receive_imf::add_parts() still adds to the db if the chat_id is TRASH
|
||||||
"UPDATE msgs \
|
"UPDATE msgs \
|
||||||
SET chat_id=?, txt='', txt_raw='', from_id=0, to_id=0, param='' \
|
SET chat_id=?, txt='', txt_raw='', mime_headers='', from_id=0, to_id=0, param='' \
|
||||||
WHERE \
|
WHERE \
|
||||||
ephemeral_timestamp != 0 \
|
ephemeral_timestamp != 0 \
|
||||||
AND ephemeral_timestamp <= ? \
|
AND ephemeral_timestamp <= ? \
|
||||||
|
|||||||
@@ -147,13 +147,17 @@ impl MsgId {
|
|||||||
|
|
||||||
/// Put message into trash chat and delete message text.
|
/// Put message into trash chat and delete message text.
|
||||||
///
|
///
|
||||||
/// It means the message is deleted locally, but not on the server
|
/// It means the message is deleted locally, but not on the server.
|
||||||
/// yet.
|
/// We keep some infos to
|
||||||
|
/// 1. not download the same message again
|
||||||
|
/// 2. be able to delete the message on the server if we want to
|
||||||
pub async fn trash(self, context: &Context) -> crate::sql::Result<()> {
|
pub async fn trash(self, context: &Context) -> crate::sql::Result<()> {
|
||||||
let chat_id = ChatId::new(DC_CHAT_ID_TRASH);
|
let chat_id = ChatId::new(DC_CHAT_ID_TRASH);
|
||||||
context
|
context
|
||||||
.sql
|
.sql
|
||||||
.execute(
|
.execute(
|
||||||
|
// If you change which information is removed here, also change delete_expired_messages() and
|
||||||
|
// which information dc_receive_imf::add_parts() still adds to the db if the chat_id is TRASH
|
||||||
"UPDATE msgs SET chat_id=?, txt='', txt_raw='', mime_headers='', from_id=0, to_id=0, param='' WHERE id=?",
|
"UPDATE msgs SET chat_id=?, txt='', txt_raw='', mime_headers='', from_id=0, to_id=0, param='' WHERE id=?",
|
||||||
paramsv![chat_id, self],
|
paramsv![chat_id, self],
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user