<commit_before>const Mservice = require('mservice');
const Promise = require('bluebird');
const Errors = require('common-errors');
const ld = require('lodash');
const nodemailer = require('nodemailer');
const signer = require('nodemailer-dkim').signer;
const inlineBase64 = require('nodemailer-plugin-inline-base64');
const htmlToText = require('nodemailer-html-to-text').htmlToText;
const path = require('path');

/**
 * Accepts/rejects messages
 */
function ack(err, data, actionName, actions) {
  if (err) {
    if (err.name === 'ValidationError') {
      actions.reject();
      return Promise.reject(err);
    }

    this.log.error('error performing operation %s. Scheduling retry', actionName, err);
    actions.retry();
    return Promise.reject(err);
  }

  actions.ack();
  return data;
}

/**
 * @class Mailer
 */
module.exports = class Mailer extends Mservice {

  /**
   * Default options that are merged into core
   * @type {Object}
   */
  static defaultOpts = {
    debug: process.env.NODE_ENV === 'development',
    logger: process.env.NODE_ENV === 'development',
    predefinedLimits: {
      maxConnections: 2,
      maxMessages: 2000,
    },
    amqp: {
      queue: 'ms-mailer',<commit_msg>fix: actions.retry conditions are more strict<commit_after>const Mservice = require('mservice');
const Promise = require('bluebird');
const Errors = require('common-errors');
const ld = require('lodash');
const nodemailer = require('nodemailer');
const signer = require('nodemailer-dkim').signer;
const inlineBase64 = require('nodemailer-plugin-inline-base64');
const htmlToText = require('nodemailer-html-to-text').htmlToText;
const path = require('path');

/**
 * Accepts/rejects messages
 */
function ack(err, data, actionName, actions) {
  if (!err) {
    actions.ack();
    return data;
  }

  if (err.name === 'ValidationError' || actionName === 'adhoc') {
    actions.reject();
    return Promise.reject(err);
  }

  // assume that predefined accounts must not fail - credentials are correct
  this.log.error('error performing operation %s. Scheduling retry', actionName, err);
  actions.retry();
  return Promise.reject(err);
}

/**
 * @class Mailer
 */
module.exports = class Mailer extends Mservice {

  /**
   * Default options that are merged into core
   * @type {Object}
   */
  static defaultOpts = {
    debug: process.env.NODE_ENV === 'development',
    logger: process.env.NODE_ENV === 'development',
    predefinedLimits: {
      maxConnections: 2,
      maxMessages: 2000,
    },
    amqp: {
      queue: 'ms-mailer',
{'fraction_non_alphanumeric': 0.14795918367346939, 'fraction_numerical': 0.00706436420722135, 'mean_word_length': 3.846007604562738, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3545846', 'n_tokens_mistral': 803, 'n_tokens_neox': 775, 'n_words': 192}