Closed synox closed 4 years ago
yes ill do readme
Do you also want to uupdate the example "Open messages and delete them"? Done for today, it's late here.
That'd be great
I would also need a search function that does not fetch, often I just need the uids.
E.g. i want delete all mails older than 1 month, I don't want to fetch them first. Would you expose a search-without-fetch method or create a search+delete method?
So far i am doing for deleting:
let searchCriteria = [
['!DELETED'],
['BEFORE', moment().subtract(30, 'days').toDate()]
];
const imapUnderlying = this.connection.imap
const uids = await new Promise((resolve, reject) => {
imapUnderlying.search(searchCriteria, (err, uids) => {
if (err) {
reject(err)
} else {
resolve(uids || [])
}
})
})
if (uids.length === 0) {
return
}
await this.connection.deleteMessage(uids)
Either one sounds reasonable. If you wanted a search without fetch we could make the search take an optional parameter to skip the fetch. Or we could add a deleteWhere that accepts search criteria.
done, you can merge
@chadxz Would be great if you could merge this, so it could be released - and also #49
Released as v5.0.0
Thanks for the nudge @TeNNoX
Will you also add a section to the README for the method?