Some fixes so that the subscription forms work with the new mailer

This commit is contained in:
Tomas Bures 2018-05-20 20:27:35 +02:00
parent 446d75ce71
commit 1f5566ca9b
5 changed files with 22 additions and 9 deletions

View file

@ -35,9 +35,13 @@ Handlebars.registerHelper('translate', function (context, options) { // eslint-d
const transports = new Map();
async function getOrCreateMailer(sendConfiguration) {
async function getOrCreateMailer(sendConfigurationId) {
let sendConfiguration;
if (!sendConfiguration) {
sendConfiguration = sendConfigurations.getSystemSendConfiguration();
sendConfiguration = await sendConfigurations.getSystemSendConfiguration();
} else {
sendConfiguration = await sendConfigurations.getById(contextHelpers.getAdminContext(), sendConfigurationId, false);
}
const transport = transports.get(sendConfiguration.id) || await _createTransport(sendConfiguration);
@ -65,8 +69,8 @@ async function _sendMail(transport, mail, template) {
const preparedHtml = await tools.prepareHtml(mail.html);
if (prepareHtml) {
mail.html = prepareHtml;
if (preparedHtml) {
mail.html = preparedHtml;
}
const textRenderer = await tools.getTemplate(template.text);

View file

@ -67,7 +67,7 @@ async function mergeTemplateIntoLayout(template, layout) {
}
if (template.endsWith('.hbs')) {
template = readFile(template);
template = await readFile(template);
}
const source = layout.replace(/\{\{\{body\}\}\}/g, template);
@ -121,7 +121,7 @@ async function prepareHtml(html) {
FetchExternalResources: false, // disables resource loading over HTTP / filesystem
ProcessExternalResources: false // do not execute JS within script blocks
}
})
});
const head = win.document.querySelector('head');
let hasCharsetTag = false;