This commit is contained in:
Chris 2020-01-08 10:58:28 +13:00
parent 9d4506977d
commit 2204bbe70c
2 changed files with 8 additions and 6 deletions

View file

@ -682,7 +682,7 @@ async function queueCampaignMessageTx(tx, sendConfigurationId, listId, subscript
});
}
async function queueAPITransactionalMessage(sendConfigurationId, email, subject, html, text, tagLanguage, mergeTags, attachments) {
async function queueAPITransactionalMessage(tx, sendConfigurationId, email, subject, html, text, tagLanguage, mergeTags, attachments) {
const msgData = {
to: {
address: email

View file

@ -163,13 +163,15 @@ async function remove(context, id) {
}
async function sendAsTransactionalEmail(context, templateId, sendConfigurationId, emails, subject, mergeTags, attachments) {
const template = await getById(context, templateId, false);
await knex.transaction(async tx => {
const template = await getById(context, templateId, false);
await shares.enforceEntityPermission(context, 'sendConfiguration', sendConfigurationId, 'sendWithoutOverrides');
await shares.enforceEntityPermission(context, 'sendConfiguration', sendConfigurationId, 'sendWithoutOverrides');
for (const email of emails) {
await messageSender.queueAPITransactionalMessage(sendConfigurationId, email, subject, template.html, template.text, template.tag_language, {...mergeTags, EMAIL: email }, attachments);
}
for (const email of emails) {
await messageSender.queueAPITransactionalMessage(tx, sendConfigurationId, email, subject, template.html, template.text, template.tag_language, {...mergeTags, EMAIL: email }, attachments);
}
});
}