From 376c8193749513af4262028a781fb6f00346c0e9 Mon Sep 17 00:00:00 2001 From: link2xt Date: Thu, 28 May 2026 13:52:37 +0200 Subject: [PATCH] feat: immediately remove all encrypted messages from the server in single-device mode --- src/ephemeral.rs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/ephemeral.rs b/src/ephemeral.rs index 29367b97f..d9ea5b16b 100644 --- a/src/ephemeral.rs +++ b/src/ephemeral.rs @@ -691,7 +691,7 @@ pub(crate) async fn delete_expired_imap_messages( (transport_id, now, DownloadState::Done), ) .await?; - } else { + } else if bcc_self { // There may be other devices using this relay, // either because there is multi-device or because this is a classical email server. // Only delete expired ephemeral messages. @@ -712,6 +712,30 @@ pub(crate) async fn delete_expired_imap_messages( (transport_id, now), ) .await?; + } else { + // Single device. + // Delete all expired and encrypted messages. + context + .sql + .execute( + "UPDATE imap + SET target='' + WHERE transport_id=?1 + AND rfc724_mid IN ( + SELECT rfc724_mid FROM msgs + WHERE id>9 + AND ((ephemeral_timestamp!=0 AND ephemeral_timestamp<=?2) OR + ((param GLOB '*\nc=1*' OR param GLOB 'c=1*') AND download_state=?3)) + UNION + SELECT pre_rfc724_mid FROM msgs + WHERE pre_rfc724_mid!='' + AND id>9 + AND ((ephemeral_timestamp!=0 AND ephemeral_timestamp<=?2) OR + (param GLOB '*\nc=1*' OR param GLOB 'c=1*')) + )", + (transport_id, now, DownloadState::Done), + ) + .await?; } Ok(())