Fixed mail-helper.js not calling back when disableConfirmations = true
And some refactoring
This commit is contained in:
parent
830ca4f17f
commit
a2ebe8f0f7
1 changed files with 19 additions and 21 deletions
|
@ -96,7 +96,7 @@ function sendMail(list, email, template, subject, relativeUrls, mailOpts, subscr
|
|||
}
|
||||
|
||||
if (!mailOpts.ignoreDisableConfirmations && configItems.disableConfirmations) {
|
||||
return;
|
||||
return callback();
|
||||
}
|
||||
|
||||
const data = {
|
||||
|
@ -110,7 +110,22 @@ function sendMail(list, email, template, subject, relativeUrls, mailOpts, subscr
|
|||
data[relativeUrlKey] = urllib.resolve(configItems.serviceUrl, relativeUrls[relativeUrlKey]);
|
||||
}
|
||||
|
||||
function sendMail(html, text) {
|
||||
let text = {
|
||||
template: 'subscription/mail-' + template + '-text.hbs'
|
||||
};
|
||||
|
||||
let html = {
|
||||
template: 'subscription/mail-' + template + '-html.mjml.hbs',
|
||||
layout: 'subscription/layout.mjml.hbs',
|
||||
type: 'mjml'
|
||||
};
|
||||
|
||||
helpers.injectCustomFormTemplates(list.defaultForm, { text, html }, (err, tmpl) => {
|
||||
if (!err && tmpl) {
|
||||
text = tmpl.text || text;
|
||||
html = tmpl.html || html;
|
||||
}
|
||||
|
||||
mailer.sendMail({
|
||||
from: {
|
||||
name: configItems.defaultFrom,
|
||||
|
@ -129,29 +144,12 @@ function sendMail(list, email, template, subject, relativeUrls, mailOpts, subscr
|
|||
}, err => {
|
||||
if (err) {
|
||||
log.error('Subscription', err);
|
||||
return callback(err);
|
||||
}
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
let text = {
|
||||
template: 'subscription/mail-' + template + '-text.hbs'
|
||||
};
|
||||
|
||||
let html = {
|
||||
template: 'subscription/mail-' + template + '-html.mjml.hbs',
|
||||
layout: 'subscription/layout.mjml.hbs',
|
||||
type: 'mjml'
|
||||
};
|
||||
|
||||
helpers.injectCustomFormTemplates(list.defaultForm, { text, html }, (err, tmpl) => {
|
||||
if (err) {
|
||||
return sendMail(html, text);
|
||||
}
|
||||
|
||||
sendMail(tmpl.html, tmpl.text);
|
||||
});
|
||||
|
||||
return callback();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue