<commit_before>'use strict';

let emailUtil = require('../lib/emailUtil');
let config = require('config');
let logger = require('../lib/logger');
let Q = require('q');

function logAndRethrow(message) {
    return function (error) {
      logger.logError(error, message);
      throw new Error(error);
    };
}

function logAndRethrow(message) {
    return function (error) {
      logger.logError(error, message);
      throw new Error(error);
    };
}

let emails = {
  welcome: {
    logger: logger.logWelcomeEmailSent,
    subject: 'The Pirate Party - Welcome',
    text: function() { return `Welcome to the Pirate Party!

        You can now start participating and getting involved towards the development of a more secure and transparent Australia.

        For a list of upcoming meetings and discussions, head to pirateparty.org.au

        Best,

        The Pirate Party`;
    }
  },
  verification: {
    logger: logger.logVerificationEmailSent,
    subject: 'The Pirate Party - Verify Your Email',
    text: function(member) { return `Hello, <br>

        Thank you for your membership application to the Pirate Party. <br>

        You're almost done! The last step is to verify your membership by clicking on the link below. <br>

        <a href="${config.app.publicUrl}/members/verify/${member.verificationHash}">Verify Account</a> <br>

        Best,<br>

        The Pirate Party`;
    }
  },
  renewal: {
    logger: logger.logMemberRenewalEmail,
    subject: 'The Pirate Party - Renew Your Membership',
    text: function(member) { return `
        Hello,

        Your Pirate Party membership is due to expire 90 days. To renew it, please click on the following link: \n

        ${config.app.publicUrl}/members/renew/${member.renewalHash} \n

        Should you have any questions or concerns, do not hesitate to contact us at <EMAIL>. \n

        Best, \n

        The Pirate Party`;
    }
  }
};

function sendEmail(member, type) {
    if (!config.get('email.sendEmails')) {
        return Q.resolve(member);
    }

    let options = {
        to: member.email,
        subject: type.subject,
        body: type.text(member)
    };

    return emailUtil.sendHtmlEmail(options)
        .then((result) => {
            return {
                options: options,
                message: result
            };
        })<commit_msg>Plain text emails as indicated on the catds :P<commit_after>'use strict';

let emailUtil = require('../lib/emailUtil');
let config = require('config');
let logger = require('../lib/logger');
let Q = require('q');

function logAndRethrow(message) {
    return function (error) {
      logger.logError(error, message);
      throw new Error(error);
    };
}

function logAndRethrow(message) {
    return function (error) {
      logger.logError(error, message);
      throw new Error(error);
    };
}

let emails = {
  welcome: {
    logger: logger.logWelcomeEmailSent,
    subject: 'The Pirate Party - Welcome',
    text: function() { return `Welcome to the Pirate Party!

        You can now start participating and getting involved towards the development of a more secure and transparent Australia.

        For a list of upcoming meetings and discussions, head to pirateparty.org.au

        Best,

        The Pirate Party`;
    }
  },
  verification: {
    logger: logger.logVerificationEmailSent,
    subject: 'The Pirate Party - Verify Your Email',
    text: function(member) { return `Hello,

        Thank you for your membership application to the Pirate Party.

        You're almost done! The last step is to verify your membership by clicking on the link below.

        ${config.app.publicUrl}/members/verify/${member.verificationHash}

        Best,

        The Pirate Party`;
    }
  },
  renewal: {
    logger: logger.logMemberRenewalEmail,
    subject: 'The Pirate Party - Renew Your Membership',
    text: function(member) { return `
        Hello,

        Your Pirate Party membership is due to expire 90 days. To renew it, please click on the following link:

        ${config.app.publicUrl}/members/renew/${member.renewalHash}

        Should you have any questions or concerns, do not hesitate to contact us at <EMAIL>.

        Best,

        The <NAME>`;
    }
  }
};

function sendEmail(member, type) {
    if (!config.get('email.sendEmails')) {
        return Q.resolve(member);
    }

    let options = {
        to: member.email,
        subject: type.subject,
        body: type.text(member)
    };

    return emailUtil.sendHtmlEmail(options)
        .then((result) => {
            return {
                options: options,
                message: result
            };
        })
{'fraction_non_alphanumeric': 0.10428265524625267, 'fraction_numerical': 0.0008565310492505353, 'mean_word_length': 2.498876404494382, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, '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': '491865', 'n_tokens_mistral': 1336, 'n_tokens_neox': 1285, 'n_words': 431}