- More options how to send test emails. - Fixed problems with pausing a campaign (#593) - Started rework of transactional sender of templates (#606), however this contains functionality regression at the moment because it does not interpret templates as HBS. It needs HBS option for templates as described in https://github.com/Mailtrain-org/mailtrain/issues/611#issuecomment-502345227 TODO: - detect sending errors connected to not able to contact the mailer and pause/retry campaing and queued sending - don't mark the recipients as BOUNCED - add FAILED campaign state and fall into it if sending to campaign consistently fails (i.e. the error with sending is not temporary) - if the same happends for queued email, delete the message
39 lines
No EOL
667 B
JavaScript
39 lines
No EOL
667 B
JavaScript
'use strict';
|
|
|
|
module.exports = {
|
|
enforce,
|
|
cleanupFromPost,
|
|
filterObject,
|
|
castToInteger
|
|
};
|
|
|
|
function enforce(condition, message) {
|
|
if (!condition) {
|
|
throw new Error(message);
|
|
}
|
|
}
|
|
|
|
function cleanupFromPost(value) {
|
|
return (value || '').toString().trim();
|
|
}
|
|
|
|
function filterObject(obj, allowedKeys) {
|
|
const result = {};
|
|
for (const key in obj) {
|
|
if (allowedKeys.has(key)) {
|
|
result[key] = obj[key];
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
function castToInteger(id, msg) {
|
|
const val = parseInt(id);
|
|
|
|
if (!Number.isInteger(val)) {
|
|
throw new Error(msg || 'Invalid id');
|
|
}
|
|
|
|
return val;
|
|
} |