<commit_before>const isProd = process.env.NODE_ENV === 'production'
const path = require('path')
const returnEmail = process.env.COMPLAINT_EMAIL
const jade = require('jade')

module.exports = function (app) {
  console.log('the app', app)
  console.log('showing notifier app value', app.get('src'))
  const returnEmail = app.get('complaint_email') || process.env.COMPLAINT_EMAIL

  function getLink(type, hash) {
    var url
    var port = (app.get('client_port') === '80' || isProd) ? '' : ':' + app.get('client_port')
    var host = (app.get('host') === 'HOST') ? 'localhost' : app.get('host')
    var protocal = (app.get('protocal') === 'PROTOCAL') ? 'http' : app.get('protocal')
    console.log('show', protocal);
    protocal += "://"
    console.log('spell', protocal);
    var accessLink = `http://tame-app.herokuapp.com/#!/${type}?token=${hash}`
    console.log('showing link sent to user', accessLink)
    return accessLink
  }

  function sendEmail(email) {
    return app.service('email').create(email).then(function (result) {
      console.log('Sent email', result)
    }).catch(err => {
      console.log('Error sending email', err)
    })
  }

  return function (type, user, notifierOptions) {
    console.log(`-- Preparing email for ${type}`)

    var hashLink
    var email
    console.log('src path', app.get('src'))
    var emailAccountTemplatesPath = path.join(app.get('src'), 'email-templates', 'account')

    var templatePath
    var compiledHTML
    switch (type) {
      case 'resendVerifySignup': // send another email with link for verifying user's email addr

        hashLink = getLink('verify', user.verifyToken)

        templatePath = path.join(emailAccountTemplatesPath, 'verify-email.jade')

        compiledHTML = jade.compileFile(templatePath)({
          logo: '',
          name: user.name || user.email,
          hashLink,
          returnEmail
        })

        email = {
          from: '<EMAIL>',
          to: user.email,
          subject: 'Confirm Signup',
          html: compiledHTML
        }

        return sendEmail(email)

        break
      case 'verifySignup': // inform that user's email is now confirmed

        hashLink = getLink('verify', user.verifyToken)

        templatePath = path.join(emailAccountTemplatesPath, 'email-verified.jade')

        compiledHTML = jade.compileFile(templatePath)({
          logo: '',
          name: user.name || user.email,
          hashLink,
          returnEmail
        })

        email = {
          from: '<EMAIL>',
          to: user.email,
          subject: 'Thank you, your email has been verified',
          html: compiledHTML
        }

        return sendEmail(email)

        break
      case 'sendResetPwd': // inform that user's email is now confirmed

        hashLink = getLink('reset', user.resetToken)<commit_msg>forgot password<commit_after>const isProd = process.env.NODE_ENV === 'production'
const path = require('path')
const returnEmail = process.env.COMPLAINT_EMAIL
const jade = require('jade')

module.exports = function (app) {
  console.log('the app', app)
  console.log('showing notifier app value', app.get('src'))
  const returnEmail = app.get('complaint_email') || process.env.COMPLAINT_EMAIL

  function getLink(type, hash) {
    var url
    var port = (app.get('client_port') === '80' || isProd) ? '' : ':' + app.get('client_port')
    var host = (app.get('host') === 'HOST') ? 'localhost' : app.get('host')
    var protocal = (app.get('protocal') === 'PROTOCAL') ? 'http' : app.get('protocal')
    console.log('show', protocal);
    protocal += "://"
    console.log('spell', protocal);
    var accessLink = `http://tame-app.herokuapp.com/#!/${type}?token=${hash}`
    console.log('showing link sent to user', accessLink)
    return accessLink
  }

  function sendEmail(email) {
    return app.service('email').create(email).then(function (result) {
      console.log('Sent email', result)
    }).catch(err => {
      console.log('Error sending email', err)
    })
  }

  return function (type, user, notifierOptions) {
    console.log(`-- Preparing email for ${type}`)

    var hashLink
    var email
    console.log('src path', app.get('src'))
    var emailAccountTemplatesPath = path.join(app.get('src'), 'email-templates', 'account')

    var templatePath
    var compiledHTML
    switch (type) {
      case 'resendVerifySignup': // send another email with link for verifying user's email addr

        hashLink = getLink('verify', user.verifyToken)

        templatePath = path.join(emailAccountTemplatesPath, 'verify-email.jade')

        compiledHTML = jade.compileFile(templatePath)({
          logo: '',
          name: user.name || user.email,
          hashLink,
          returnEmail
        })

        email = {
          from: '<EMAIL>',
          to: user.email,
          subject: 'Confirm Signup',
          html: compiledHTML
        }

        return sendEmail(email)

        break
      case 'verifySignup': // inform that user's email is now confirmed

        hashLink = getLink('verify', user.verifyToken)

        templatePath = path.join(emailAccountTemplatesPath, 'email-verified.jade')

        compiledHTML = jade.compileFile(templatePath)({
          logo: '',
          name: user.name || user.email,
          hashLink,
          returnEmail
        })

        email = {
          from: '<EMAIL>',
          to: user.email,
          subject: 'Thank you, your email has been verified',
          html: compiledHTML
        }

        return sendEmail(email)

        break
      case 'sendResetPwd': // inform that user's email is now confirmed

        hashLink = getLink('forgotpassword', user.resetToken)
{'fraction_non_alphanumeric': 0.14021490223709707, 'fraction_numerical': 0.0007045974986788797, 'mean_word_length': 2.6774611398963732, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 9, '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': '823355', 'n_tokens_mistral': 1699, 'n_tokens_neox': 1655, 'n_words': 400}