mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
Delete messages more thoroughly (and at all) (#2114)
- Make sure delete_expired_messages and housekeeping runs once a day - delete more info about messages when putting them to trash (esp. also delete txt_raw, from_id and to_id as we don't need those anymore, so they are data that was unnecessarily kept) fix #1926, fix #2090 Also: * Nicer test_utils: add send_text() and print_chat() * Adapt ephemeral messages for testing (make them accurate to the second) * Add test for ephemeral messages * Make pop_sent_msg() really pop the last sent message
This commit is contained in:
17
src/sql.rs
17
src/sql.rs
@@ -9,7 +9,6 @@ use std::time::Duration;
|
||||
|
||||
use rusqlite::{Connection, Error as SqlError, OpenFlags};
|
||||
|
||||
use crate::chat::{update_device_icon, update_saved_messages_icon};
|
||||
use crate::constants::{ShowEmails, DC_CHAT_ID_TRASH};
|
||||
use crate::context::Context;
|
||||
use crate::dc_tools::*;
|
||||
@@ -17,6 +16,10 @@ use crate::ephemeral::start_ephemeral_timers;
|
||||
use crate::error::format_err;
|
||||
use crate::param::*;
|
||||
use crate::peerstate::*;
|
||||
use crate::{
|
||||
chat::{update_device_icon, update_saved_messages_icon},
|
||||
config::Config,
|
||||
};
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! paramsv {
|
||||
@@ -465,6 +468,10 @@ pub fn get_rowid2(
|
||||
}
|
||||
|
||||
pub async fn housekeeping(context: &Context) {
|
||||
if let Err(err) = crate::ephemeral::delete_expired_messages(context).await {
|
||||
warn!(context, "Failed to delete expired messages: {}", err);
|
||||
}
|
||||
|
||||
let mut files_in_use = HashSet::new();
|
||||
let mut unreferenced_count = 0;
|
||||
|
||||
@@ -595,7 +602,13 @@ pub async fn housekeeping(context: &Context) {
|
||||
);
|
||||
}
|
||||
|
||||
info!(context, "Housekeeping done.",);
|
||||
if let Err(e) = context
|
||||
.set_config(Config::LastHousekeeping, Some(&time().to_string()))
|
||||
.await
|
||||
{
|
||||
warn!(context, "Can't set config: {}", e);
|
||||
}
|
||||
info!(context, "Housekeeping done.");
|
||||
}
|
||||
|
||||
#[allow(clippy::indexing_slicing)]
|
||||
|
||||
Reference in New Issue
Block a user