From 021365f615b8ef6629fc3a7145de32c59e5b79a5 Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Sun, 14 Apr 2024 12:14:52 -0700 Subject: [PATCH] tweak --- CHANGELOG.md | 3 ++- lib/connection.js | 26 ++++++++++++-------------- lib/transaction.js | 2 +- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b0a601d..e7fa28d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,10 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). ### [1.3.6] - 2024-04-14 -- connection: import more from haraka/Haraka/connection - transaction: sync with haraka/Haraka +- connection: import more from haraka/Haraka/connection - test(conn): expect more connection properties - doc(CONTRIBUTING): added +- doc(README): added example setup ### [1.3.5] - 2024-04-07 diff --git a/lib/connection.js b/lib/connection.js index 0160a24..2e2ecac 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -13,15 +13,7 @@ class Connection { constructor(client, server, cfg) { this.client = client this.server = server - this.cfg = - cfg || - config.get('smtp.ini', { - booleans: [ - '+main.smtputf8', - '+headers.add_received', - '+headers.clean_auth_results', - ], - }) + this.cfg = cfg this.local = { ip: null, @@ -250,9 +242,15 @@ class Connection { exports.Connection = Connection -exports.createConnection = function (client, server) { - if (typeof client === 'undefined') client = {} - if (typeof server === 'undefined') server = {} - - return new Connection(client, server) +exports.createConnection = function (client = {}, server = {}, cfg = {}) { + if (!cfg || Object.keys(cfg).length === 0) { + cfg = config.get('smtp.ini', { + booleans: [ + '+main.smtputf8', + '+headers.add_received', + '+headers.clean_auth_results', + ], + }) + } + return new Connection(client, server, cfg) } diff --git a/lib/transaction.js b/lib/transaction.js index c0a47d7..fdc3aeb 100644 --- a/lib/transaction.js +++ b/lib/transaction.js @@ -3,7 +3,7 @@ const util = require('util') const Notes = require('haraka-notes') -const utils = require('haraka-utils'); +const utils = require('haraka-utils') const message = require('haraka-email-message') const logger = require('./logger')