From 93c147e73b5faafe15c64f9030d6d5d3c2f640cd Mon Sep 17 00:00:00 2001 From: Nedim Uka Date: Tue, 2 Jul 2019 11:54:33 +0200 Subject: [PATCH] Looged amazon send bulk email response, fixed some emails not sent bug --- app/helpers/awsEmail.js | 11 +++++++---- app/services/notificationService.js | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/helpers/awsEmail.js b/app/helpers/awsEmail.js index f72a896..218a368 100644 --- a/app/helpers/awsEmail.js +++ b/app/helpers/awsEmail.js @@ -123,6 +123,7 @@ const sendBulkEmail = async (marketAlerts) => { }) } + console.log("AWS EMAIL : Bulk email replacement data:"); console.log(destinations); var params = { @@ -138,7 +139,9 @@ const sendBulkEmail = async (marketAlerts) => { // Create the promise and SES service object const sendPromise = new AWS.SES({ apiVersion: '2010-12-01' }).sendBulkTemplatedEmail(params).promise(); - await sendPromise; + const awsResult = await sendPromise; + console.log("AWS SES bulk email response"); + console.log(awsResult); } catch (e) { @@ -151,10 +154,10 @@ const sendBulkEmail = async (marketAlerts) => { const toAWSArray = (urlArray) => { let arrayString = "" urlArray.forEach(element => { - arrayString = arrayString + `{"url":"${element.url}" , "title":"${element.title}"},` + arrayString = arrayString + `{"url":"${element.url.trim()}" , "title":"${element.title.replace(/"/g, "")}"},` }); - return arrayString.slice(0, -1);; + return arrayString.slice(0, -1); } const getNotificationEmailHtml = () => { @@ -177,7 +180,7 @@ const createMarketAlertEmailTemplate = async () => { Template: { TemplateName: "MarketAlertTemplate", SubjectPart: "Javi mi obavijest", - TextPart: "Dear ,\r\nYour favorite animal is {{marketAlertUrl}}.", + TextPart: getNotificationEmailText(), HtmlPart: getNotificationEmailHtml() } } diff --git a/app/services/notificationService.js b/app/services/notificationService.js index 14d45d4..f299330 100644 --- a/app/services/notificationService.js +++ b/app/services/notificationService.js @@ -16,6 +16,7 @@ async function processNotifications() { await sendBulkEmail(marketAlerts); } else { console.log("NOTIFICATION SERVICE: No new alerts"); + return; } await db.MarketAlert.update(