|
|
|
@ -28,7 +28,7 @@ async function sendPage(payload) {
|
|
|
|
|
}
|
|
|
|
|
async function processMail(mail) {
|
|
|
|
|
let handling = "default"
|
|
|
|
|
let payload = config.handling[handling]
|
|
|
|
|
let payload = config.handling.processing[handling]
|
|
|
|
|
payload = payload.replace("[subject]", mail.subject)
|
|
|
|
|
payload = payload.replace("[from]", mail.from.text)
|
|
|
|
|
payload = payload.replace("[fromName]", mail.from.value.name || mail.from.value.address)
|
|
|
|
@ -40,6 +40,9 @@ function ScanUnread() {
|
|
|
|
|
.then(() => $ImapConnection.search(searchCriteria, fetchOptions))
|
|
|
|
|
.then((emails) => {
|
|
|
|
|
console.log('unreadCount:', emails.length)
|
|
|
|
|
if (config.handling.onlySimpleCounter === true) {
|
|
|
|
|
sendPage(config.handling.onlySimpleCounterFormat.replace("[unreadCount]", emails.length))
|
|
|
|
|
} else {
|
|
|
|
|
for (let mail of emails) {
|
|
|
|
|
const all = mail.parts.filter(x => x.which == '')[0]
|
|
|
|
|
const idHeader = `Imap-Id: ${mail.attributes.uid}\r\n`
|
|
|
|
@ -47,6 +50,7 @@ function ScanUnread() {
|
|
|
|
|
ignoreImapIDs.push(mail.attributes.uid)
|
|
|
|
|
mailparser.simpleParser(idHeader + all.body).then(processMail)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
main()
|