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) {
|
async deleteOldMails(deleteMailsBefore) {
|
||||||
let uids = []
|
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(), deleteMailsBefore)) {
|
||||||
if (helper.moreThanOneDay(moment() + 24 * 60 * 60 * 1000, deleteMailsBefore)) {
|
|
||||||
uids = await this._searchWithoutFetch([
|
uids = await this._searchWithoutFetch([
|
||||||
['!DELETED'],
|
['!DELETED'],
|
||||||
['BEFORE', deleteMailsBefore]
|
['BEFORE', deleteMailsBefore]
|
||||||
])
|
])
|
||||||
} else {
|
} 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([
|
uids = await this._searchWithoutFetch([
|
||||||
['!DELETED'],
|
['!DELETED'],
|
||||||
|
['BEFORE', deleteMailsBefore]
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -218,8 +220,8 @@ class ImapService extends EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
const DeleteOlderThan = helper.purgeTimeStamp()
|
const DeleteOlderThan = helper.purgeTimeStamp()
|
||||||
const uidsWithHeaders = await this._getMailHeaders(uids)
|
|
||||||
|
|
||||||
|
const uidsWithHeaders = await this._getMailHeaders(uids)
|
||||||
uidsWithHeaders.forEach(mail => {
|
uidsWithHeaders.forEach(mail => {
|
||||||
if (mail['attributes'].date > DeleteOlderThan || this.config.email.examples.uids.includes(parseInt(mail['attributes'].uid))) {
|
if (mail['attributes'].date > DeleteOlderThan || this.config.email.examples.uids.includes(parseInt(mail['attributes'].uid))) {
|
||||||
uids = uids.filter(uid => uid !== mail['attributes'].uid)
|
uids = uids.filter(uid => uid !== mail['attributes'].uid)
|
||||||
|
|
@ -345,7 +347,6 @@ class ImapService extends EventEmitter {
|
||||||
|
|
||||||
async _getMailHeaders(uids) {
|
async _getMailHeaders(uids) {
|
||||||
const fetchOptions = {
|
const fetchOptions = {
|
||||||
envelope: true,
|
|
||||||
bodies: ['HEADER.FIELDS (FROM TO SUBJECT DATE)'],
|
bodies: ['HEADER.FIELDS (FROM TO SUBJECT DATE)'],
|
||||||
struct: false
|
struct: false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,11 +27,7 @@ class MailRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
add(to, mailSummary) {
|
add(to, mailSummary) {
|
||||||
if (to !== undefined) {
|
this.mailSummaries.set(to.toLowerCase(), mailSummary)
|
||||||
this.mailSummaries.set(to.toLowerCase(), mailSummary)
|
|
||||||
} else {
|
|
||||||
debug('IMAP reported no recipient for mail, ignoring', mailSummary)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
removeUid(uid, address) {
|
removeUid(uid, address) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue