<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('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://${host}${port}/#!/login/${type}?token=${hash}`
    console.log('showing link sent to user', accessLink )
    return accessLink
  }

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

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

      var hashLink
      var email
      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)

          templatePath = path.join(emailAccountTemplatesPath, 'reset-password.jade')

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

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

          return sendEmail(email)

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

          hashLink = getLink('reset', user.resetToken)

          templatePath = path.join(emailAccountTemplatesPath, 'password-was-reset.jade')

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

          email = {
            from: '<EMAIL>',
             to: user.email,
             subject: 'Your password was reset',
             html: compiledHTML
          }

          return sendEmail(email)

          break
        case 'passwordChange':

          templatePath = path.join(emailAccountTemplatesPath, 'password-change.jade')

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

          email = {
            from: '<EMAIL>',
             to: user.email,
             subject: 'Your password was changed',
             html: compiledHTML
          }

          return sendEmail(email)

          break
        case 'identityChange':
          hashLink = getLink('verifyChanges', user.verifyToken)

          templatePath = path.join(emailAccountTemplatesPath, 'identity-change.jade')

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

          email = {
            from: '<EMAIL>',
             to: user.email,
             subject: 'Your account was changed. Please verify the changes',
             html: compiledHTML
          }

          return sendEmail(email)
          break
        default:
          break
      }
    }
  }
}
<commit_msg>modified notifier to fit to server config<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('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/#!/login/${type}?token=${hash}`
    console.log('showing link sent to user', accessLink )
    return accessLink
  }

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

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

      var hashLink
      var email
      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)

          templatePath = path.join(emailAccountTemplatesPath, 'reset-password.jade')

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

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

          return sendEmail(email)

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

          hashLink = getLink('reset', user.resetToken)

          templatePath = path.join(emailAccountTemplatesPath, 'password-was-reset.jade')

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

          email = {
            from: '<EMAIL>',
             to: user.email,
             subject: 'Your password was reset',
             html: compiledHTML
          }

          return sendEmail(email)

          break
        case 'passwordChange':

          templatePath = path.join(emailAccountTemplatesPath, 'password-change.jade')

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

          email = {
            from: '<EMAIL>',
             to: user.email,
             subject: 'Your password was changed',
             html: compiledHTML
          }

          return sendEmail(email)

          break
        case 'identityChange':
          hashLink = getLink('verifyChanges', user.verifyToken)

          templatePath = path.join(emailAccountTemplatesPath, 'identity-change.jade')

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

          email = {
            from: '<EMAIL>',
             to: user.email,
             subject: 'Your account was changed. Please verify the changes',
             html: compiledHTML
          }

          return sendEmail(email)
          break
        default:
          break
      }
    }
  }
}

{'fraction_non_alphanumeric': 0.11704173879592229, 'fraction_numerical': 0.00038468936333910367, 'mean_word_length': 1.8537321624588365, 'pattern_counts': {'":': 2, '<': 15, '<?xml version=': 0, '>': 17, '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': '962275', 'n_tokens_mistral': 2826, 'n_tokens_neox': 2749, 'n_words': 644}