From 5a908548617c56e5aca928d4151593eb95a14ed4 Mon Sep 17 00:00:00 2001 From: Dave Richer Date: Thu, 10 Oct 2024 13:01:36 -0400 Subject: [PATCH] feature/IO-2979-DST-Handling - Checkpoint Signed-off-by: Dave Richer --- docker-compose.yml | 6 +++++- nodemon.json | 35 ++++++++++++++++++++++++++++++++ server/email/mailer.js | 18 ---------------- server/email/tasksEmails.js | 23 +++++++++++++++++++++ server/email/tasksEmailsQueue.js | 2 +- 5 files changed, 64 insertions(+), 20 deletions(-) create mode 100644 nodemon.json diff --git a/docker-compose.yml b/docker-compose.yml index 1bd0bc423..dd8dac175 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -63,6 +63,7 @@ services: retries: 10 # LocalStack: Used to emulate AWS services locally, currently setup for SES + # Notes: Set the ENV Debug to 1 for additional logging localstack: image: localstack/localstack container_name: localstack @@ -74,10 +75,13 @@ services: - /var/run/docker.sock:/var/run/docker.sock environment: - SERVICES=ses - - DEBUG=1 + - DEBUG=0 - AWS_ACCESS_KEY_ID=test - AWS_SECRET_ACCESS_KEY=test - AWS_DEFAULT_REGION=ca-central-1 + - EXTRA_CORS_ALLOWED_HEADERS=Authorization,Content-Type + - EXTRA_CORS_ALLOWED_ORIGINS=* + - EXTRA_CORS_EXPOSE_HEADERS=Authorization,Content-Type ports: - "4566:4566" healthcheck: diff --git a/nodemon.json b/nodemon.json new file mode 100644 index 000000000..e267a23c7 --- /dev/null +++ b/nodemon.json @@ -0,0 +1,35 @@ +{ + "watch": [ + "server.js", + "server" + ], + "ignore": [ + "client", + ".circleci", + ".platform", + ".idea", + ".vscode", + "_reference", + "firebase", + "hasura", + "logs", + "redis", + ".dockerignore", + ".ebignore", + ".editorconfig", + ".env.development", + ".env.development.rome", + ".eslintrc.json", + ".gitignore", + ".npmmrc", + ".prettierrc.js", + "bodyshop_translations.babel", + "Dockerfile", + "ecosystem.config.js", + "job-totals-testing-util.js", + "nodemon.json", + "package.json", + "package-lock.json", + "setadmin.js" + ] +} diff --git a/server/email/mailer.js b/server/email/mailer.js index 78e02037e..6503e1f8c 100644 --- a/server/email/mailer.js +++ b/server/email/mailer.js @@ -28,22 +28,4 @@ let transporter = nodemailer.createTransport({ SES: { ses, aws } }); -if (isLocal) { - // Wrap the sendMail function to log the email contents to the console in local environment - const originalSendMail = transporter.sendMail.bind(transporter); - transporter.sendMail = async (mailOptions) => { - try { - const result = await originalSendMail(mailOptions); - console.log( - `Email sent successfully - From: ${result?.envelope?.from} - To: ${result?.envelope?.to} - MessageID ${result.messageId} - Check LocalStack to see message` - ); - - return result; - } catch (error) { - console.error("Failed to send email:", error); - throw error; - } - }; -} - module.exports = transporter; diff --git a/server/email/tasksEmails.js b/server/email/tasksEmails.js index ea99a2d23..189471e5a 100644 --- a/server/email/tasksEmails.js +++ b/server/email/tasksEmails.js @@ -324,6 +324,29 @@ const tasksRemindEmail = async (req, res) => { } }; +// Note: Uncomment this to test locally, it will call the remind_at email check every 20 seconds +// const callTaskRemindEmailInternally = () => { +// const req = { +// body: { +// // You can mock any request data here if needed +// } +// }; +// +// const res = { +// status: (code) => { +// return { +// json: (data) => { +// console.log(`Response Status: ${code}`, data); +// } +// }; +// } +// }; +// +// // Call the taskRemindEmail function with mock req and res +// tasksRemindEmail(req, res); +// }; +// setInterval(callTaskRemindEmailInternally, 20000); + module.exports = { taskAssignedEmail, tasksRemindEmail, diff --git a/server/email/tasksEmailsQueue.js b/server/email/tasksEmailsQueue.js index dc004abc1..b01c9aa14 100644 --- a/server/email/tasksEmailsQueue.js +++ b/server/email/tasksEmailsQueue.js @@ -13,7 +13,7 @@ const taskEmailQueue = () => console.log("Processing reminds for taskIds: ", taskIds.join(", ")); // Set the remind_at_sent to the current time. - const now = moment().toISOString(); + const now = moment.utc().toISOString(); client .request(UPDATE_TASKS_REMIND_AT_SENT, { taskIds, now })