mirror of
https://github.com/Crazyco-xyz/48hr.email.git
synced 2025-11-04 15:26:33 +01:00
Compare commits
No commits in common. "e158fac4147449d8ab4b1b659d6cf0c4c7e3f0e7" and "f2e69239539ec6e3f7e0e41b23707d0f159ee3f5" have entirely different histories.
e158fac414
...
f2e6923953
2 changed files with 6 additions and 9 deletions
|
|
@ -201,15 +201,17 @@ class ImapService extends EventEmitter {
|
|||
*/
|
||||
async deleteOldMails(deleteMailsBefore) {
|
||||
let uids = []
|
||||
//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)) {
|
||||
if (helper.moreThanOneDay(moment(), 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]
|
||||
])
|
||||
}
|
||||
|
||||
|
|
@ -218,8 +220,8 @@ class ImapService extends EventEmitter {
|
|||
}
|
||||
|
||||
const DeleteOlderThan = helper.purgeTimeStamp()
|
||||
const uidsWithHeaders = await this._getMailHeaders(uids)
|
||||
|
||||
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)
|
||||
|
|
@ -345,7 +347,6 @@ class ImapService extends EventEmitter {
|
|||
|
||||
async _getMailHeaders(uids) {
|
||||
const fetchOptions = {
|
||||
envelope: true,
|
||||
bodies: ['HEADER.FIELDS (FROM TO SUBJECT DATE)'],
|
||||
struct: false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,11 +27,7 @@ class MailRepository {
|
|||
}
|
||||
|
||||
add(to, mailSummary) {
|
||||
if (to !== undefined) {
|
||||
this.mailSummaries.set(to.toLowerCase(), mailSummary)
|
||||
} else {
|
||||
debug('IMAP reported no recipient for mail, ignoring', mailSummary)
|
||||
}
|
||||
this.mailSummaries.set(to.toLowerCase(), mailSummary)
|
||||
}
|
||||
|
||||
removeUid(uid, address) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue