retire userRemoveUid function, refactor removeUid

pull/16/head
ClaraCrazy 2024-10-02 02:36:58 +02:00
parent 1d42862c46
commit 92674272d5
No known key found for this signature in database
GPG Key ID: EBBC896ACB497011
2 changed files with 17 additions and 26 deletions

View File

@ -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)
} }
} }

View File

@ -30,31 +30,22 @@ class MailRepository {
this.mailSummaries.set(to.toLowerCase(), mailSummary) this.mailSummaries.set(to.toLowerCase(), mailSummary)
} }
UserRemoveUid(address, uid) { removeUid(uid, address) {
var deleted = false if (!this.config.http.examples.uids.includes(parseInt(uid))) {
// TODO: make this more efficient, looping through each email is not cool. var deleted = false
this.mailSummaries.forEachAssociation((mails, to) => { // TODO: make this more efficient, looping through each email is not cool.
mails this.mailSummaries.forEachAssociation((mails, to) => {
.filter(mail => mail.uid === parseInt(uid) & to == address) mails
.forEach(mail => { .filter(mail => mail.uid === parseInt(uid) && (address ? to == address : true))
this.mailSummaries.remove(to, mail) .forEach(mail => {
debug('removed ', mail.date, to, mail.subject) this.mailSummaries.remove(to, mail)
deleted = true debug('removed ', mail.date, to, mail.subject)
}) deleted = true
}) })
return deleted })
} return deleted
}
removeUid(uid) { return false
// 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() {