From a9d790acbf693753965714943af4d19a1d2f193f Mon Sep 17 00:00:00 2001 From: Andris Reinman Date: Fri, 19 Jan 2024 15:40:55 +0200 Subject: [PATCH] Fixed breaking tests --- lib/bounces.js | 17 ++++++++++------- lib/mail-queue.js | 2 +- lib/sender.js | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/bounces.js b/lib/bounces.js index e1dc4ec..6febaac 100644 --- a/lib/bounces.js +++ b/lib/bounces.js @@ -106,10 +106,13 @@ module.exports.check = (input, category) => { }; }; -module.exports.canSendBounce = delivery => { +module.exports.canSendBounce = (delivery, options) => { + options = options || {}; + let logName = options.logName || 'Bounce'; + if (delivery.skipBounce) { log.info( - this.logName, + logName, 'id=%s %s.%s SKIPBOUNCE Skip bounce to %s as defined by routing', delivery.sessionId, delivery.id, @@ -121,7 +124,7 @@ module.exports.canSendBounce = delivery => { if (/^mailer-daemon@/i.test(delivery.from) || !delivery.from) { log.info( - this.logName, + logName, 'id=%s %s.%s SKIPBOUNCE Skip bounce to %s due to envelope (MAIL FROM=%s)', delivery.sessionId, delivery.id, @@ -137,7 +140,7 @@ module.exports.canSendBounce = delivery => { let xAutoResponseSuppress = delivery.headers.getFirst('X-Auto-Response-Suppress'); if (/\ball\b/i.test(xAutoResponseSuppress)) { log.info( - this.logName, + logName, 'id=%s %s.%s SKIPBOUNCE Skip bounce to %s due to header (%s=%s)', delivery.sessionId, delivery.id, @@ -152,7 +155,7 @@ module.exports.canSendBounce = delivery => { let autoSubmitted = delivery.headers.getFirst('Auto-Submitted'); if (/\bauto-(generated|replied)\b/i.test(autoSubmitted)) { log.info( - this.logName, + logName, 'id=%s %s.%s SKIPBOUNCE Skip bounce to %s due to header (%s=%s)', delivery.sessionId, delivery.id, @@ -167,7 +170,7 @@ module.exports.canSendBounce = delivery => { let contentType = delivery.headers.getFirst('Content-Type'); if (/^multipart\/report\b/i.test(contentType)) { log.info( - this.logName, + logName, 'id=%s %s.%s SKIPBOUNCE Skip bounce to %s due to header (%s=%s)', delivery.sessionId, delivery.id, @@ -181,7 +184,7 @@ module.exports.canSendBounce = delivery => { if (delivery.parsedEnvelope && /^mailer-daemon@/i.test(delivery.parsedEnvelope.from)) { log.info( - this.logName, + logName, 'id=%s %s.%s SKIPBOUNCE Skip bounce to %s due to header (%s=%s)', delivery.sessionId, delivery.id, diff --git a/lib/mail-queue.js b/lib/mail-queue.js index d924663..8014c32 100644 --- a/lib/mail-queue.js +++ b/lib/mail-queue.js @@ -837,7 +837,7 @@ class MailQueue { to: deliveryEntry.recipient }; - if (!bounces.canSendBounce(deliveryEntry)) { + if (!bounces.canSendBounce(deliveryEntry, { logName: 'Queue' })) { return false; } diff --git a/lib/sender.js b/lib/sender.js index 67ff099..c5e56df 100644 --- a/lib/sender.js +++ b/lib/sender.js @@ -1416,7 +1416,7 @@ class Sender extends EventEmitter { } sendBounceMessage(delivery, bounce, smtpResponse) { - if (!bounces.canSendBounce(delivery)) { + if (!bounces.canSendBounce(delivery, { logName: this.logName })) { return false; }