Skip to content

Commit 6f5d7ea

Browse files
author
Hamid Tavakoli
committed
add more email logging and fix model.save
1 parent 8c624da commit 6f5d7ea

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

connect/service.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const sendEmail = async (templateId, message) => { // send email
5656
const sgSpan = await logger.startSpan('sendgrid');
5757
const result = await sgMail.send(msg)
5858
await logger.endSpan(sgSpan);
59-
logger.info(`Email sent successfully with result: ${JSON.stringify(result)}`);
59+
logger.info(`Email sent successfully with result: ${JSON.stringify(result)} \n ${JSON.stringify(msg)}`);
6060
return result
6161
} catch (err) {
6262
logger.error(`Error occurred in sendgrid api calling: ${err}`);

src/init.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ async function dataHandler(consumer, handlers) {
7070
recipients: JSON.stringify(messageJSON.recipients),
7171
}
7272

73-
await emailModel.create(emailInfo)
73+
const emailObj = await emailModel.create(emailInfo)
7474
const result = await handler(topicName, messageJSON);
7575

7676
logger.info('info', 'Email sent', {
@@ -83,8 +83,8 @@ async function dataHandler(consumer, handlers) {
8383
const emailTries = {}
8484
if (result.success) {
8585
emailTries[topicName] = 0;
86-
emailModel.status = 'SUCCESS';
87-
await emailModel.save();
86+
emailObj.status = 'SUCCESS';
87+
await emailObj.save();
8888
} else {
8989
// emailTries[topicName] += 1; //temporary disabling this feature
9090
if (result.error) {

0 commit comments

Comments
 (0)