From 80d8ecfad25178da57ec2a3181b9a3fca3203aec Mon Sep 17 00:00:00 2001 From: ClaraCrazy Date: Tue, 3 Dec 2024 07:55:13 +0100 Subject: [PATCH] Fix the fix that fixes the hotfix for fixing time - or something --- application/imap-service.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/application/imap-service.js b/application/imap-service.js index 9c24806..09117be 100644 --- a/application/imap-service.js +++ b/application/imap-service.js @@ -201,17 +201,15 @@ class ImapService extends EventEmitter { */ async deleteOldMails(deleteMailsBefore) { let uids = [] - if (helper.moreThanOneDay(moment(), deleteMailsBefore)) { + //fetch mails from date +1day (calculated in MS) to avoid wasting resources and to fix imaps missing time-awareness + if (helper.moreThanOneDay(moment() + 24 * 60 * 60 * 1000, deleteMailsBefore)) { uids = await this._searchWithoutFetch([ ['!DELETED'], ['BEFORE', deleteMailsBefore] ]) } else { - //fetch mails from date -1day (calculated in MS) to avoid wasting resources - deleteMailsBefore = new Date(moment() - 24 * 60 * 60 * 1000) uids = await this._searchWithoutFetch([ ['!DELETED'], - ['BEFORE', deleteMailsBefore] ]) } @@ -220,8 +218,8 @@ class ImapService extends EventEmitter { } const DeleteOlderThan = helper.purgeTimeStamp() - const uidsWithHeaders = await this._getMailHeaders(uids) + uidsWithHeaders.forEach(mail => { if (mail['attributes'].date > DeleteOlderThan || this.config.email.examples.uids.includes(parseInt(mail['attributes'].uid))) { uids = uids.filter(uid => uid !== mail['attributes'].uid)