feature/IO-3492-FCM-Queue-For-Notifications: Implement FCM queue and worker for notifications

This commit is contained in:
Dave
2026-01-05 12:46:09 -05:00
parent 4a7bb07345
commit 4190372b92
8 changed files with 558 additions and 156 deletions

View File

@@ -75,7 +75,9 @@ const loadEmailQueue = async ({ pubClient, logger }) => {
await pubClient.hsetnx(detailsKey, "lastName", lastName || "");
await pubClient.hsetnx(detailsKey, "bodyShopTimezone", bodyShopTimezone);
await pubClient.expire(detailsKey, NOTIFICATION_EXPIRATION / 1000);
await pubClient.sadd(`email:${devKey}:recipients:${jobId}`, user);
const recipientsSetKey = `email:${devKey}:recipients:${jobId}`;
await pubClient.sadd(recipientsSetKey, user);
await pubClient.expire(recipientsSetKey, NOTIFICATION_EXPIRATION / 1000);
devDebugLogger(`Stored message for ${user} under ${userKey}: ${body}`);
}
@@ -239,7 +241,13 @@ const dispatchEmailsToQueue = async ({ emailsToDispatch, logger }) => {
const emailAddQueue = getQueue();
for (const email of emailsToDispatch) {
const { jobId, jobRoNumber, bodyShopName, bodyShopTimezone, body, recipients } = email;
const { jobId, bodyShopName, bodyShopTimezone, body, recipients } = email;
let { jobRoNumber } = email;
// Make sure Jobs that have not been coverted yet can still get notifications
if (jobRoNumber === null) {
jobRoNumber = "N/A";
}
if (!jobId || !jobRoNumber || !bodyShopName || !body || !recipients.length) {
devDebugLogger(