Skip to content

Commit

Permalink
Merge pull request #15 from haraka/14-not-defined
Browse files Browse the repository at this point in the history
hoist variables above first use
  • Loading branch information
msimerson authored Dec 6, 2018
2 parents 295b240 + 64225fd commit 9f5b365
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ build/Release
# Dependency directories
node_modules
jspm_packages
package-lock.json

# Optional npm cache directory
.npm
Expand Down
4 changes: 4 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

# 1.0.6 - 2018-12-06

- move declarations up to restore `var` variable hoisting behavior

# 1.0.5 - 2018-11-16

- reduce severity of log message when no passing dkim results
Expand Down
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ exports.update_sender = function (next, connection, params) {
// queue_ok arguments: next, connection, msg
// ok 1390590369 qp 634 (F82E2DD5-9238-41DC-BC95-9C3A02716AD2.1)

let sender_od;
let rcpt_domains;

function errNext (err) {
connection.logerror(plugin, 'update_sender: ' + err);
next(null, null, sender_od, rcpt_domains);
Expand All @@ -52,10 +55,10 @@ exports.update_sender = function (next, connection, params) {
if (!connection.relaying) return next();
const txn = connection.transaction;

const sender_od = plugin.get_sender_domain_by_txn(txn);
sender_od = plugin.get_sender_domain_by_txn(txn);
if (!sender_od) return errNext('no sender domain');

const rcpt_domains = plugin.get_recipient_domains_by_txn(txn);
rcpt_domains = plugin.get_recipient_domains_by_txn(txn);
if (rcpt_domains.length === 0) {
return errNext('no rcpt ODs for ' + sender_od);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "haraka-plugin-known-senders",
"version": "1.0.5",
"version": "1.0.6",
"description": "Increase the reputation of recognized sender domains.",
"main": "index.js",
"scripts": {
Expand Down
18 changes: 9 additions & 9 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('is_authenticated', function () {
},
connection);
});
});
})

describe('check_recipient', function () {
let connection;
Expand All @@ -110,7 +110,7 @@ describe('check_recipient', function () {
connection,
new Address('<user@host.example.com>'));
});
});
})

describe('update_sender', function () {

Expand Down Expand Up @@ -165,13 +165,13 @@ describe('update_sender', function () {
},
connection);
});
});
})

describe('get_rcpt_ods', function () {
it('always returns an array', function (done) {
done();
});
});
})

describe('get_sender_domain_by_txn', function () {

Expand Down Expand Up @@ -203,7 +203,7 @@ describe('get_sender_domain_by_txn', function () {
assert.equal(plugin.get_sender_domain_by_txn(this.connection.transaction), 'bbc.co.uk');
done();
});
});
})

describe('get_recipient_domains_by_txn', function () {

Expand Down Expand Up @@ -244,7 +244,7 @@ describe('get_recipient_domains_by_txn', function () {
assert.deepEqual(rcpt_doms, ['example.com'], rcpt_doms);
done();
});
});
})

describe('is_dkim_authenticated', function () {

Expand All @@ -259,7 +259,7 @@ describe('is_dkim_authenticated', function () {
this.connection.transaction.results = new fixtures.result_store(this.connection);

done();
});
})

after(function (done) {
this.plugin.shutdown();
Expand All @@ -280,5 +280,5 @@ describe('is_dkim_authenticated', function () {
done();
},
connection);
});
});
})
})

0 comments on commit 9f5b365

Please sign in to comment.