mirror of
https://github.com/chatmail/core.git
synced 2026-10-03 03:30:36 +03:00
refactor: make should_delete_all_downloaded_messages non-async
Pass bcc_self into it as a boolean.
This commit is contained in:
+3
-1
@@ -6,6 +6,7 @@ use anyhow::{Result, anyhow, bail, ensure};
|
||||
use deltachat_derive::{FromSql, ToSql};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::context::Context;
|
||||
use crate::imap::session::Session;
|
||||
use crate::log::warn;
|
||||
@@ -169,7 +170,8 @@ pub(crate) async fn download_msg(
|
||||
}
|
||||
Box::pin(session.fetch_single_msg(context, &server_folder, server_uid, rfc724_mid)).await?;
|
||||
|
||||
if ephemeral::should_delete_all_downloaded_messages(context, session.is_chatmail()).await? {
|
||||
let bcc_self = context.get_config_bool(Config::BccSelf).await?;
|
||||
if ephemeral::should_delete_all_downloaded_messages(bcc_self, session.is_chatmail()) {
|
||||
// Now that the message was downloaded, it likely needs to be deleted;
|
||||
// trigger a re-check by interrupting the inbox folder.
|
||||
// This is mainly needed to make the tests pass;
|
||||
|
||||
+4
-6
@@ -663,7 +663,8 @@ pub(crate) async fn delete_expired_imap_messages(
|
||||
) -> Result<()> {
|
||||
let now = time();
|
||||
|
||||
if should_delete_all_downloaded_messages(context, is_chatmail).await? {
|
||||
let bcc_self = context.get_config_bool(Config::BccSelf).await?;
|
||||
if should_delete_all_downloaded_messages(bcc_self, is_chatmail) {
|
||||
// This is the only device using this relay.
|
||||
// Mark all downloaded messages for deletion, because they are not needed anymore.
|
||||
//
|
||||
@@ -716,11 +717,8 @@ pub(crate) async fn delete_expired_imap_messages(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn should_delete_all_downloaded_messages(
|
||||
context: &Context,
|
||||
is_chatmail: bool,
|
||||
) -> Result<bool> {
|
||||
Ok(!context.get_config_bool(Config::BccSelf).await? && is_chatmail)
|
||||
pub(crate) fn should_delete_all_downloaded_messages(bcc_self: bool, is_chatmail: bool) -> bool {
|
||||
!bcc_self && is_chatmail
|
||||
}
|
||||
|
||||
/// Start ephemeral timers for seen messages if they are not started
|
||||
|
||||
Reference in New Issue
Block a user