Skip to content

Commit

Permalink
Merge pull request #10 from nodemailer/ZMS-63
Browse files Browse the repository at this point in the history
ZMS 63
  • Loading branch information
andris9 authored Dec 14, 2023
2 parents 73cee37 + 770807c commit 0b8f581
Show file tree
Hide file tree
Showing 3 changed files with 799 additions and 607 deletions.
44 changes: 44 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1225,6 +1225,50 @@ module.exports.init = function (app, done) {
return next();
});

app.addHook('sender:responseError', async (delivery) => {
let deferTimesStr = await settingsHandler.get('const:sender:defer_times');
if (deferTimesStr) {
const deferTimes = deferTimesStr
.split(',')
.map((v) => {
let m = v.match(/\s*(\d+)\s*([^\d\s]+)?\s*/);
if (!m) {
return false;
}
const n = Number(m[1]);
const l = (m[2] || '').toLowerCase();

switch (l) {
case 's':
case 'sec':
case 'second':
case 'seconds':
return n * 1000;

case 'm':
case 'min':
return n * 60 * 1000;

case 'h':
case 'hour':
return n * 60 * 60 * 1000;

case 'd':
case 'day':
case 'days':
return n * 24 * 60 * 60 * 1000;

default:
return n;
}
})
.filter((v) => v);
if (deferTimes && deferTimes.length) {
delivery.deferTimes = deferTimes;
}
}
});

function checkInterface(iface) {
if (allInterfaces || interfaces.includes(iface)) {
return true;
Expand Down
Loading

0 comments on commit 0b8f581

Please sign in to comment.