fix(email): better promise handling

This commit is contained in:
Sabe Jones
2019-11-19 12:53:21 -06:00
parent 85c979a22d
commit 46822ecbae
2 changed files with 4 additions and 4 deletions

View File

@@ -16,11 +16,11 @@ async function updateUser (user) {
if (count % progressCount === 0) console.warn(`${count} ${user._id}`); if (count % progressCount === 0) console.warn(`${count} ${user._id}`);
sendTxn( await sendTxn(
user, user,
EMAIL_SLUG, EMAIL_SLUG,
[{ name: 'BASE_URL', content: BASE_URL }], // Add variables from template [{ name: 'BASE_URL', content: BASE_URL }], // Add variables from template
); ).catch(err => console.error(err));
return User.update({ _id: user._id }, { $set: { migration: MIGRATION_NAME } }).exec(); return User.update({ _id: user._id }, { $set: { migration: MIGRATION_NAME } }).exec();
} }

View File

@@ -66,7 +66,7 @@ export function getGroupUrl (group) {
} }
// Send a transactional email using Mandrill through the external email server // Send a transactional email using Mandrill through the external email server
export function sendTxn (mailingInfoArray, emailType, variables, personalVariables) { export async function sendTxn (mailingInfoArray, emailType, variables, personalVariables) {
mailingInfoArray = Array.isArray(mailingInfoArray) ? mailingInfoArray : [mailingInfoArray]; // eslint-disable-line no-param-reassign, max-len mailingInfoArray = Array.isArray(mailingInfoArray) ? mailingInfoArray : [mailingInfoArray]; // eslint-disable-line no-param-reassign, max-len
variables = [ // eslint-disable-line no-param-reassign, max-len variables = [ // eslint-disable-line no-param-reassign, max-len
@@ -130,7 +130,7 @@ export function sendTxn (mailingInfoArray, emailType, variables, personalVariabl
} }
if (IS_PROD && mailingInfoArray.length > 0) { if (IS_PROD && mailingInfoArray.length > 0) {
got.post(`${EMAIL_SERVER.url}/job`, { return got.post(`${EMAIL_SERVER.url}/job`, {
auth: `${EMAIL_SERVER.auth.user}:${EMAIL_SERVER.auth.password}`, auth: `${EMAIL_SERVER.auth.user}:${EMAIL_SERVER.auth.password}`,
json: true, json: true,
body: { body: {