From 0e9e3f1d9a1b811537b20b2d3f67e2a24cd8e406 Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Fri, 19 Apr 2024 02:50:55 -0700 Subject: [PATCH] dep(punycode.js), reduced indirection, spread operator (#35) * punycode.js: also update package.json * remove unused indirection, use es6 ... to reduce boilerplate * lint: turn off prefer-const warnings * update GHA workflows * pr fix: call open_database in register * revert eslint rule --- .github/workflows/release.yaml | 4 ++-- .github/workflows/test.yml | 6 +++--- index.js | 20 ++++---------------- package-lock.json | 2 +- package.json | 2 +- 5 files changed, 11 insertions(+), 23 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2ab6c7c..c750f46 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -20,11 +20,11 @@ jobs: package-name: ${{env.NPM_MODULE_NAME}} pull-request-title-pattern: 'chore${scope}: release ${version} [skip-ci]' # The logic below handles the npm publication: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # these if statements ensure that a publication only occurs when # a new release is created: if: ${{ steps.release.outputs.release_created }} - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: node-version: 18 registry-url: 'https://registry.npmjs.org' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e7147db..344acca 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,13 +8,13 @@ jobs: test: strategy: matrix: - node: [16.x, 18.x, 20.x] + node: [16, 18, 20] os: [ubuntu-latest] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node }} - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} - run: npm install diff --git a/index.js b/index.js index 9a7079e..7b22a28 100644 --- a/index.js +++ b/index.js @@ -44,8 +44,8 @@ exports.register = function () { plugin.logdebug('Initializing Wild Duck plugin.'); plugin.load_wildduck_ini(); - plugin.register_hook('init_master', 'init_wildduck_shared'); - plugin.register_hook('init_child', 'init_wildduck_shared'); + plugin.register_hook('init_master', 'open_database'); + plugin.register_hook('init_child', 'open_database'); plugin.resolver = async (name, rr) => await dns.promises.resolve(name, rr); }; @@ -64,7 +64,7 @@ exports.load_wildduck_ini = function () { ); }; -exports.open_database = function (server, next) { +exports.open_database = function (next, server) { const plugin = this; plugin.srsRewriter = new SRS({ @@ -129,13 +129,7 @@ exports.open_database = function (server, next) { plugin.db.messageHandler.loggelf = message => plugin.loggelf(message); plugin.db.userHandler.loggelf = message => plugin.loggelf(message); - plugin.maildrop = new Maildropper({ - db, - enabled: plugin.cfg.sender.enabled, - zone: plugin.cfg.sender.zone, - collection: plugin.cfg.sender.collection, - gfs: plugin.cfg.sender.gfs - }); + plugin.maildrop = new Maildropper({ db, ...plugin.cfg.sender }); plugin.filterHandler = new FilterHandler({ db, @@ -194,12 +188,6 @@ exports.normalize_address = function (address) { return tools.normalizeAddress(address.address()); }; -exports.init_wildduck_shared = function (next, server) { - const plugin = this; - - plugin.open_database(server, next); -}; - exports.increment_forward_counters = async function (connection) { const plugin = this; const txn = connection.transaction; diff --git a/package-lock.json b/package-lock.json index 06c7ad7..8c94c62 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,7 @@ "mailauth": "4.6.5", "mongodb": "4.17.0", "nodemailer": "6.9.13", - "punycode": "2.3.1", + "punycode.js": "2.3.1", "srs.js": "0.1.0", "wildduck": "1.42.5" }, diff --git a/package.json b/package.json index dcfbe2b..88a44da 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "mailauth": "4.6.5", "mongodb": "4.17.0", "nodemailer": "6.9.13", - "punycode": "2.3.1", + "punycode.js": "2.3.1", "srs.js": "0.1.0", "wildduck": "1.42.5" }