feature/IO-3492-FCM-Queue-For-Notifications: Implement FCM queue and worker for notifications
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user