Compare commits

..

4 commits

Author SHA1 Message Date
ClaraCrazy
e158fac414
add debug statement to failing to if-branch 2024-12-03 08:00:13 +01:00
ClaraCrazy
367c4a688b
Properly check for UNDEFINED 2024-12-03 07:57:12 +01:00
ClaraCrazy
80d8ecfad2
Fix the fix that fixes the hotfix for fixing time - or something 2024-12-03 07:55:13 +01:00
ClaraCrazy
e99a8b55e0
Avoid unpredictable behaviour on weird undisclosed recipients:; signal
IMAP does not return the bcc field cleanly, in fact, node-imap and by extension imap-simple wont return a valid bcc (or cc for that matter) at all.
Generally, you can only view those with the "envelope" attribute of a mail, but those are empty. Only clean option would be to somehow accesss and work with the rfc822 spec of `Original-Recipient`.
2024-12-03 07:54:27 +01:00
2 changed files with 9 additions and 6 deletions

View file

@ -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)
@ -347,6 +345,7 @@ class ImapService extends EventEmitter {
async _getMailHeaders(uids) {
const fetchOptions = {
envelope: true,
bodies: ['HEADER.FIELDS (FROM TO SUBJECT DATE)'],
struct: false
}

View file

@ -27,7 +27,11 @@ class MailRepository {
}
add(to, mailSummary) {
this.mailSummaries.set(to.toLowerCase(), mailSummary)
if (to !== undefined) {
this.mailSummaries.set(to.toLowerCase(), mailSummary)
} else {
debug('IMAP reported no recipient for mail, ignoring', mailSummary)
}
}
removeUid(uid, address) {