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

@@ -19,6 +19,8 @@ const buildNotification = (data, key, body, variables = {}) => {
jobId: data.jobId,
jobRoNumber: data.jobRoNumber,
bodyShopId: data.bodyShopId,
scenarioKey: data.scenarioKey,
scenarioTable: data.scenarioTable,
key,
body,
variables,
@@ -32,21 +34,47 @@ const buildNotification = (data, key, body, variables = {}) => {
body,
recipients: []
},
fcm: { recipients: [] }
fcm: {
jobId: data.jobId,
jobRoNumber: data.jobRoNumber,
bodyShopId: data.bodyShopId,
bodyShopName: data.bodyShopName,
bodyShopTimezone: data.bodyShopTimezone,
scenarioKey: data.scenarioKey,
scenarioTable: data.scenarioTable,
key,
body,
variables,
recipients: []
}
};
// Populate recipients from scenarioWatchers
data.scenarioWatchers.forEach((recipients) => {
const { user, app, fcm, email, firstName, lastName, employeeId, associationId } = recipients;
if (app === true)
if (app === true) {
result.app.recipients.push({
user,
bodyShopId: data.bodyShopId,
employeeId,
associationId
});
if (fcm === true) result.fcm.recipients.push(user);
if (email === true) result.email.recipients.push({ user, firstName, lastName });
}
if (email === true) {
result.email.recipients.push({ user, firstName, lastName });
}
if (fcm === true) {
// Keep structure consistent and future-proof (token lookup is done server-side)
result.fcm.recipients.push({
user,
bodyShopId: data.bodyShopId,
employeeId,
associationId
});
}
});
return result;