Looged amazon send bulk email response, fixed some emails not sent bug

This commit is contained in:
Nedim Uka
2019-07-02 11:54:33 +02:00
parent 96e9da1fb1
commit 93c147e73b
2 changed files with 8 additions and 4 deletions

View File

@@ -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()
}
}

View File

@@ -16,6 +16,7 @@ async function processNotifications() {
await sendBulkEmail(marketAlerts);
} else {
console.log("NOTIFICATION SERVICE: No new alerts");
return;
}
await db.MarketAlert.update(