retire userRemoveUid function, refactor removeUid
parent
1d42862c46
commit
92674272d5
|
@ -32,7 +32,7 @@ class MailProcessingService extends EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteSpecificEmail(adress, uid) {
|
deleteSpecificEmail(adress, uid) {
|
||||||
if (this.mailRepository.UserRemoveUid(adress, uid) == true) {
|
if (this.mailRepository.removeUid(uid, adress) == true) {
|
||||||
this.imapService.deleteSpecificEmail(uid)
|
this.imapService.deleteSpecificEmail(uid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,12 +30,13 @@ class MailRepository {
|
||||||
this.mailSummaries.set(to.toLowerCase(), mailSummary)
|
this.mailSummaries.set(to.toLowerCase(), mailSummary)
|
||||||
}
|
}
|
||||||
|
|
||||||
UserRemoveUid(address, uid) {
|
removeUid(uid, address) {
|
||||||
|
if (!this.config.http.examples.uids.includes(parseInt(uid))) {
|
||||||
var deleted = false
|
var deleted = false
|
||||||
// TODO: make this more efficient, looping through each email is not cool.
|
// TODO: make this more efficient, looping through each email is not cool.
|
||||||
this.mailSummaries.forEachAssociation((mails, to) => {
|
this.mailSummaries.forEachAssociation((mails, to) => {
|
||||||
mails
|
mails
|
||||||
.filter(mail => mail.uid === parseInt(uid) & to == address)
|
.filter(mail => mail.uid === parseInt(uid) && (address ? to == address : true))
|
||||||
.forEach(mail => {
|
.forEach(mail => {
|
||||||
this.mailSummaries.remove(to, mail)
|
this.mailSummaries.remove(to, mail)
|
||||||
debug('removed ', mail.date, to, mail.subject)
|
debug('removed ', mail.date, to, mail.subject)
|
||||||
|
@ -44,17 +45,7 @@ class MailRepository {
|
||||||
})
|
})
|
||||||
return deleted
|
return deleted
|
||||||
}
|
}
|
||||||
|
return false
|
||||||
removeUid(uid) {
|
|
||||||
// TODO: make this more efficient, looping through each email is not cool.
|
|
||||||
this.mailSummaries.forEachAssociation((mails, to) => {
|
|
||||||
mails
|
|
||||||
.filter(mail => mail.uid === parseInt(uid))
|
|
||||||
.forEach(mail => {
|
|
||||||
this.mailSummaries.remove(to, mail)
|
|
||||||
debug('removed ', mail.date, to, mail.subject)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mailCount() {
|
mailCount() {
|
||||||
|
|
Loading…
Reference in New Issue