mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-10-06 03:14:39 +08:00
make changes requested before pull
This commit is contained in:
parent
cb20f8cecd
commit
5868fb5207
2 changed files with 6 additions and 6 deletions
|
@ -74,8 +74,7 @@ module.exports = (server) => {
|
||||||
return reply(Serialization.jsonStringify(contact))
|
return reply(Serialization.jsonStringify(contact))
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.log('Error fetching contacts: ', error)
|
request.info(error, 'Error fetching contacts')
|
||||||
reply(error)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
|
|
||||||
class ContactProcessor {
|
class ContactProcessor {
|
||||||
|
|
||||||
verified(contact) {
|
verified(logger, contact) {
|
||||||
// some suggestions: http://stackoverflow.com/questions/6317714/apache-camel-mail-to-identify-auto-generated-messages
|
// some suggestions: http://stackoverflow.com/questions/6317714/apache-camel-mail-to-identify-auto-generated-messages
|
||||||
const regex = new RegExp(/^(noreply|no-reply|donotreply|mailer|support|webmaster|news(letter)?@)/ig)
|
const regex = new RegExp(/^(noreply|no-reply|donotreply|mailer|support|webmaster|news(letter)?@)/ig)
|
||||||
|
|
||||||
if (regex.test(contact.email) || contact.email.length > 60) {
|
if (regex.test(contact.email) || contact.email.length > 60) {
|
||||||
console.log('Email address doesn\'t seem to be areal person')
|
logger.info('Email address doesn\'t seem to be areal person')
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
@ -25,15 +25,16 @@ class ContactProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
processMessage({db, message}) {
|
processMessage({db, message, logger}) {
|
||||||
const {Contact} = db;
|
const {Contact} = db;
|
||||||
|
this.logger = logger
|
||||||
|
|
||||||
let allContacts = []
|
let allContacts = []
|
||||||
const fields = ['to', 'from', 'bcc', 'cc']
|
const fields = ['to', 'from', 'bcc', 'cc']
|
||||||
fields.forEach((field) => {
|
fields.forEach((field) => {
|
||||||
allContacts = allContacts.concat(message[field])
|
allContacts = allContacts.concat(message[field])
|
||||||
})
|
})
|
||||||
const filtered = allContacts.filter(this.verified)
|
const filtered = allContacts.filter(this.verified(logger))
|
||||||
const contactPromises = filtered.map((contact) => {
|
const contactPromises = filtered.map((contact) => {
|
||||||
return this.findOrCreateByContactId(Contact, contact, message.accountId)
|
return this.findOrCreateByContactId(Contact, contact, message.accountId)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Reference in a new issue