Skip to content

Commit

Permalink
lint: prefer-template
Browse files Browse the repository at this point in the history
  • Loading branch information
msimerson committed May 24, 2022
1 parent 829a05b commit c1d438b
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
const tlds = require('haraka-tld');

exports.register = function () {
const plugin = this;
plugin.inherits('haraka-plugin-redis');
this.inherits('haraka-plugin-redis');

plugin.load_sender_ini();
this.load_sender_ini();

plugin.register_hook('init_master', 'init_redis_plugin');
plugin.register_hook('init_child', 'init_redis_plugin');
this.register_hook('init_master', 'init_redis_plugin');
this.register_hook('init_child', 'init_redis_plugin');

plugin.register_hook('mail', 'is_authenticated');
plugin.register_hook('rcpt_ok', 'check_recipient');
plugin.register_hook('queue_ok', 'update_sender');
plugin.register_hook('data_post', 'is_dkim_authenticated');
this.register_hook('mail', 'is_authenticated');
this.register_hook('rcpt_ok', 'check_recipient');
this.register_hook('queue_ok', 'update_sender');
this.register_hook('data_post', 'is_dkim_authenticated');
}

exports.load_sender_ini = function () {
Expand Down Expand Up @@ -45,7 +44,7 @@ exports.update_sender = function (next, connection, params) {
let rcpt_domains;

function errNext (err) {
connection.logerror(plugin, 'update_sender: ' + err);
connection.logerror(plugin, `update_sender: ${err}`);
next(null, null, sender_od, rcpt_domains);
}

Expand All @@ -60,7 +59,7 @@ exports.update_sender = function (next, connection, params) {

rcpt_domains = plugin.get_recipient_domains_by_txn(txn);
if (rcpt_domains.length === 0) {
return errNext('no rcpt ODs for ' + sender_od);
return errNext(`no rcpt ODs for ${sender_od}`);
}

// within this function, the sender is a local domain
Expand Down Expand Up @@ -104,7 +103,7 @@ exports.get_recipient_domains_by_txn = function (txn) {
if (!txn.rcpt_to[i].host) continue;
const rcpt_od = tlds.get_organizational_domain(txn.rcpt_to[i].host);
if (txn.rcpt_to[i].host !== rcpt_od) {
plugin.loginfo('rcpt: ' + txn.rcpt_to[i].host + ' -> ' + rcpt_od);
plugin.loginfo(`rcpt: ${txn.rcpt_to[i].host} -> ${rcpt_od}`);
}
if (rcpt_domains.indexOf(rcpt_od) === -1) {
// not a duplicate, add to the list
Expand Down Expand Up @@ -188,15 +187,15 @@ exports.check_recipient = function (next, connection, rcpt) {
if (connection.relaying) return next();

function errNext (err) {
connection.logerror(plugin, 'check_recipient: ' + err);
connection.logerror(plugin, `check_recipient: ${err}`);
next();
}

if (!rcpt.host) return errNext('rcpt.host unset?');

// reduce the host portion of the email address to an OD
const rcpt_od = tlds.get_organizational_domain(rcpt.host);
if (!rcpt_od) return errNext('no rcpt od for ' + rcpt.host);
if (!rcpt_od) return errNext(`no rcpt od for ${rcpt.host}`);

connection.transaction.results.push(plugin, { rcpt_ods: rcpt_od });

Expand Down

0 comments on commit c1d438b

Please sign in to comment.