Add example mail(s)
parent
84338ee1c1
commit
1d42862c46
|
@ -14,7 +14,11 @@ const config = {
|
|||
},
|
||||
http: {
|
||||
port: normalizePort(process.env.HTTP_PORT || 3000),
|
||||
branding: process.env.HTTP_BRANDING || ["48hr.email", "CrazyCo", "https://crazyco.xyz"]
|
||||
branding: process.env.HTTP_BRANDING || ["48hr.email", "CrazyCo", "https://crazyco.xyz"],
|
||||
examples: process.env.HTTP_EXAMPLES || {
|
||||
email: "example@48hr.email",
|
||||
ids: [1, 2, 3]
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -213,7 +213,7 @@ class ImapService extends EventEmitter {
|
|||
|
||||
const uidsWithHeaders = await this._getMailHeaders(uids)
|
||||
uidsWithHeaders.forEach(mail => {
|
||||
if (mail['attributes'].date > DeleteOlderThan) {
|
||||
if (mail['attributes'].date > DeleteOlderThan || this.config.http.examples.uids.includes(parseInt(mail['attributes'].id))) {
|
||||
uids.filter(uid => uid !== mail['attributes'].uid)
|
||||
}
|
||||
})
|
||||
|
@ -235,9 +235,11 @@ class ImapService extends EventEmitter {
|
|||
*/
|
||||
async deleteSpecificEmail(uid) {
|
||||
debug(`deleting mails ${uid}`)
|
||||
await this.connection.deleteMessage(uid)
|
||||
console.log(`deleted mail with UID: ${uid}.`)
|
||||
this.emit(ImapService.EVENT_DELETED_MAIL, uid)
|
||||
if (!this.config.http.examples.uids.includes(parseInt(uid))) {
|
||||
await this.connection.deleteMessage(uid)
|
||||
console.log(`deleted mail with UID: ${uid}.`)
|
||||
this.emit(ImapService.EVENT_DELETED_MAIL, uid)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,15 +1,23 @@
|
|||
const debug = require('debug')('48hr-email:mail-summary-store')
|
||||
const MultiMap = require('mnemonist/multi-map')
|
||||
const _ = require('lodash')
|
||||
const config = require('../application/config')
|
||||
|
||||
class MailRepository {
|
||||
constructor() {
|
||||
// MultiMap docs: https://yomguithereal.github.io/mnemonist/multi-map
|
||||
this.mailSummaries = new MultiMap()
|
||||
this.config = config
|
||||
}
|
||||
|
||||
getForRecipient(address) {
|
||||
const mails = this.mailSummaries.get(address) || []
|
||||
let mails = this.mailSummaries.get(address) || []
|
||||
mails.forEach(mail => {
|
||||
if (mail.to == this.config.http.examples.email && !this.config.http.examples.uids.includes(parseInt(mail.uid))) {
|
||||
mails = mails.filter(m => m.uid != mail.uid)
|
||||
console.log('prevent non-example email from being shown', mail.uid)
|
||||
}
|
||||
})
|
||||
return _.orderBy(mails, mail => Date.parse(mail.date), ['desc'])
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue