Looged amazon send bulk email response, fixed some emails not sent bug
This commit is contained in:
@@ -123,6 +123,7 @@ const sendBulkEmail = async (marketAlerts) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
console.log("AWS EMAIL : Bulk email replacement data:");
|
||||||
console.log(destinations);
|
console.log(destinations);
|
||||||
|
|
||||||
var params = {
|
var params = {
|
||||||
@@ -138,7 +139,9 @@ const sendBulkEmail = async (marketAlerts) => {
|
|||||||
|
|
||||||
// Create the promise and SES service object
|
// Create the promise and SES service object
|
||||||
const sendPromise = new AWS.SES({ apiVersion: '2010-12-01' }).sendBulkTemplatedEmail(params).promise();
|
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) {
|
} catch (e) {
|
||||||
@@ -151,10 +154,10 @@ const sendBulkEmail = async (marketAlerts) => {
|
|||||||
const toAWSArray = (urlArray) => {
|
const toAWSArray = (urlArray) => {
|
||||||
let arrayString = ""
|
let arrayString = ""
|
||||||
urlArray.forEach(element => {
|
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 = () => {
|
const getNotificationEmailHtml = () => {
|
||||||
@@ -177,7 +180,7 @@ const createMarketAlertEmailTemplate = async () => {
|
|||||||
Template: {
|
Template: {
|
||||||
TemplateName: "MarketAlertTemplate",
|
TemplateName: "MarketAlertTemplate",
|
||||||
SubjectPart: "Javi mi obavijest",
|
SubjectPart: "Javi mi obavijest",
|
||||||
TextPart: "Dear ,\r\nYour favorite animal is {{marketAlertUrl}}.",
|
TextPart: getNotificationEmailText(),
|
||||||
HtmlPart: getNotificationEmailHtml()
|
HtmlPart: getNotificationEmailHtml()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ async function processNotifications() {
|
|||||||
await sendBulkEmail(marketAlerts);
|
await sendBulkEmail(marketAlerts);
|
||||||
} else {
|
} else {
|
||||||
console.log("NOTIFICATION SERVICE: No new alerts");
|
console.log("NOTIFICATION SERVICE: No new alerts");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await db.MarketAlert.update(
|
await db.MarketAlert.update(
|
||||||
|
|||||||
Reference in New Issue
Block a user