Skip to content

Commit

Permalink
Fixed breaking tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andris9 committed Jan 19, 2024
1 parent ea1301e commit a9d790a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
17 changes: 10 additions & 7 deletions lib/bounces.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lib/mail-queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ class MailQueue {
to: deliveryEntry.recipient
};

if (!bounces.canSendBounce(deliveryEntry)) {
if (!bounces.canSendBounce(deliveryEntry, { logName: 'Queue' })) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/sender.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit a9d790a

Please sign in to comment.