<commit_before>
class ContactProcessor {

  verified(logger, contact) {
    // 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)

    if (regex.test(contact.email) || contact.email.length > 60) {
      logger.info('Email address doesn\'t seem to be areal person')
      return false
    }
    return true
  }

  emptyContact(Contact, options = {}, accountId) {
    options.accountId = accountId
    return Contact.create(options)
  }

  findOrCreateByContactId(Contact, contact, accountId) {
    return Contact.find({where: {email: contact.email}})
    .then((contactDb) => {
      return contactDb || this.emptyContact(Contact, contact, accountId)
    })
  }


  processMessage({db, message, logger}) {
    const {Contact} = db;
    this.logger = logger

    let allContacts = []
    const fields = ['to', 'from', 'bcc', 'cc']
    fields.forEach((field) => {
      allContacts = allContacts.concat(message[field])
    })
    const filtered = allContacts.filter(this.verified(logger))
    const contactPromises = filtered.map((contact) => {<commit_msg>replaced console logs with new logger<commit_after>
class ContactProcessor {

  verified(contact) {
    // 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)

    if (regex.test(contact.email) || contact.email.length > 60) {
      return false
    }
    return true
  }

  emptyContact(Contact, options = {}, accountId) {
    options.accountId = accountId
    return Contact.create(options)
  }

  findOrCreateByContactId(Contact, contact, accountId) {
    return Contact.find({where: {email: contact.email}})
    .then((contactDb) => {
      return contactDb || this.emptyContact(Contact, contact, accountId)
    })
  }


  processMessage({db, message, logger}) {
    const {Contact} = db;
    this.logger = logger

    let allContacts = []
    const fields = ['to', 'from', 'bcc', 'cc']
    fields.forEach((field) => {
      allContacts = allContacts.concat(message[field])
    })
    const filtered = allContacts.filter(this.verified)
    const contactPromises = filtered.map((contact) => {
{'fraction_non_alphanumeric': 0.13926174496644295, 'fraction_numerical': 0.007550335570469799, 'mean_word_length': 3.7041420118343193, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5624668', 'n_tokens_mistral': 752, 'n_tokens_neox': 720, 'n_words': 142}