Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ pub(crate) async fn download_msg(
Box::pin(session.fetch_single_msg(context, &server_folder, server_uid, rfc724_mid)).await?;

let bcc_self = context.get_config_bool(Config::BccSelf).await?;
if ephemeral::should_delete_all_downloaded_messages(bcc_self, session.is_chatmail()) {
let is_nauta = ephemeral::is_nauta(context, transport_id).await?;
if ephemeral::should_delete_all_downloaded_messages(bcc_self, session.is_chatmail(), is_nauta) {
// 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;
Expand Down
30 changes: 27 additions & 3 deletions src/ephemeral.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,9 @@ pub(crate) async fn delete_expired_imap_messages(
let now = time();

let bcc_self = context.get_config_bool(Config::BccSelf).await?;
if should_delete_all_downloaded_messages(bcc_self, is_chatmail) {
let is_nauta = is_nauta(context, transport_id).await?;

if should_delete_all_downloaded_messages(bcc_self, is_chatmail, is_nauta) {
// This is the only device using this relay.
// Mark all downloaded messages for deletion, because they are not needed anymore.
//
Expand Down Expand Up @@ -741,8 +743,30 @@ pub(crate) async fn delete_expired_imap_messages(
Ok(())
}

pub(crate) fn should_delete_all_downloaded_messages(bcc_self: bool, is_chatmail: bool) -> bool {
!bcc_self && is_chatmail
pub(crate) async fn is_nauta(context: &Context, transport_id: u32) -> Result<bool> {
let nauta_id = "nauta.cu";
debug_assert!({
// Check that the "nauta.cu" ID was spelled correctly:
let nauta = crate::provider::get_provider_by_id(nauta_id);
nauta.is_some_and(|p| p.id == nauta_id)
});

let is_nauta = crate::transport::ConfiguredLoginParam::load_all(context)
.await?
.iter()
.filter(|(tid, _)| *tid == transport_id)
.filter_map(|(_, param)| param.provider)
.next()
.is_some_and(|provider| provider.id == nauta_id);
Ok(is_nauta)
}

pub(crate) fn should_delete_all_downloaded_messages(
bcc_self: bool,
is_chatmail: bool,
is_nauta: bool,
) -> bool {
!bcc_self && (is_chatmail || is_nauta)
}

/// Start ephemeral timers for seen messages if they are not started
Expand Down
Loading