Merge pull request #407 from bluewave-labs/fix/emailService

Fixed unawaited promise in email service
This commit is contained in:
Alexander Holliday authored and GitHub committed 2024-07-22 09:49:32 -07:00
commit 9cfe52411f
1 file changed
+8 -4
+8 -4
View File
@@ -66,10 +66,10 @@ class EmailService {
* @returns {Promise<string>} A promise that resolves to the messageId of the sent email. * @returns {Promise<string>} A promise that resolves to the messageId of the sent email.
*/ */
buildAndSendEmail = async (template, context, to, subject) => { buildAndSendEmail = async (template, context, to, subject) => {
const buildHtml = (template, context) => { const buildHtml = async (template, context) => {
const mjml = this.templateLookup[template](context); const mjml = this.templateLookup[template](context);
const html = mjml2html(mjml).html; const html = await mjml2html(mjml);
return html; return html.html;
}; };
const sendEmail = async (to, subject, html) => { const sendEmail = async (to, subject, html) => {
@@ -80,7 +80,11 @@ class EmailService {
}); });
return info; return info;
}; };
const info = await sendEmail(to, subject, buildHtml(template, context)); const info = await sendEmail(
to,
subject,
await buildHtml(template, context)
);
return info.messageId; return info.messageId;
}; };
} }