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) {
|
if (!mailOpts.ignoreDisableConfirmations && configItems.disableConfirmations) {
|
||||||
return;
|
return callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
|
@ -110,7 +110,22 @@ function sendMail(list, email, template, subject, relativeUrls, mailOpts, subscr
|
||||||
data[relativeUrlKey] = urllib.resolve(configItems.serviceUrl, relativeUrls[relativeUrlKey]);
|
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({
|
mailer.sendMail({
|
||||||
from: {
|
from: {
|
||||||
name: configItems.defaultFrom,
|
name: configItems.defaultFrom,
|
||||||
|
@ -129,29 +144,12 @@ function sendMail(list, email, template, subject, relativeUrls, mailOpts, subscr
|
||||||
}, err => {
|
}, err => {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error('Subscription', 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…
Add table
Add a link
Reference in a new issue