feature/IO-3096-GlobalNotifications - Checkpoint, Builders
This commit is contained in:
@@ -10,8 +10,8 @@
|
|||||||
* @param {string} params.table - The name of the table where the event occurred.
|
* @param {string} params.table - The name of the table where the event occurred.
|
||||||
* @param {string} [params.jobIdField] - The field name or key path (e.g., "req.body.event.new.jobid") used to extract the job ID.
|
* @param {string} [params.jobIdField] - The field name or key path (e.g., "req.body.event.new.jobid") used to extract the job ID.
|
||||||
* @returns {Promise<Object>} An object containing:
|
* @returns {Promise<Object>} An object containing:
|
||||||
* - {@link changedFieldNames}: An array of field names that have changed.
|
* - {string[]} changedFieldNames - An array of field names that have changed.
|
||||||
* - {@link changedFields}: An object mapping changed field names to their new values (or `null` if the field was removed).
|
* - {Object} changedFields - An object mapping changed field names to an object with `old` and `new` values.
|
||||||
* - {boolean} isNew - Indicates if the event is for new data (i.e., no oldData exists).
|
* - {boolean} isNew - Indicates if the event is for new data (i.e., no oldData exists).
|
||||||
* - {Object} data - The new data.
|
* - {Object} data - The new data.
|
||||||
* - {string} trigger - The event trigger.
|
* - {string} trigger - The event trigger.
|
||||||
@@ -24,8 +24,10 @@ const eventParser = async ({ oldData, newData, trigger, table, jobIdField }) =>
|
|||||||
let changedFieldNames = [];
|
let changedFieldNames = [];
|
||||||
|
|
||||||
if (isNew) {
|
if (isNew) {
|
||||||
// If there's no old data, every field in newData is considered changed (new)
|
// If there's no old data, every field in newData is considered new
|
||||||
changedFields = { ...newData };
|
changedFields = Object.fromEntries(
|
||||||
|
Object.entries(newData).map(([key, value]) => [key, { old: undefined, new: value }])
|
||||||
|
);
|
||||||
changedFieldNames = Object.keys(newData);
|
changedFieldNames = Object.keys(newData);
|
||||||
} else {
|
} else {
|
||||||
// Compare oldData with newData for changes
|
// Compare oldData with newData for changes
|
||||||
@@ -36,7 +38,10 @@ const eventParser = async ({ oldData, newData, trigger, table, jobIdField }) =>
|
|||||||
!Object.prototype.hasOwnProperty.call(oldData, key) ||
|
!Object.prototype.hasOwnProperty.call(oldData, key) ||
|
||||||
JSON.stringify(oldData[key]) !== JSON.stringify(newData[key])
|
JSON.stringify(oldData[key]) !== JSON.stringify(newData[key])
|
||||||
) {
|
) {
|
||||||
changedFields[key] = newData[key];
|
changedFields[key] = {
|
||||||
|
old: oldData[key], // Could be undefined if key didn’t exist in oldData
|
||||||
|
new: newData[key]
|
||||||
|
};
|
||||||
changedFieldNames.push(key);
|
changedFieldNames.push(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -44,22 +49,23 @@ const eventParser = async ({ oldData, newData, trigger, table, jobIdField }) =>
|
|||||||
// Check for fields that were removed
|
// Check for fields that were removed
|
||||||
for (const key in oldData) {
|
for (const key in oldData) {
|
||||||
if (Object.prototype.hasOwnProperty.call(oldData, key) && !Object.prototype.hasOwnProperty.call(newData, key)) {
|
if (Object.prototype.hasOwnProperty.call(oldData, key) && !Object.prototype.hasOwnProperty.call(newData, key)) {
|
||||||
changedFields[key] = null; // Indicate field was removed
|
changedFields[key] = {
|
||||||
|
old: oldData[key],
|
||||||
|
new: null // Indicate field was removed
|
||||||
|
};
|
||||||
changedFieldNames.push(key);
|
changedFieldNames.push(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract jobId based on jobIdField
|
// Extract jobId based on jobIdField
|
||||||
let jobId = null;
|
let jobId = null;
|
||||||
if (jobIdField) {
|
if (jobIdField) {
|
||||||
// If the jobIdField is provided as a string like "req.body.event.new.jobid",
|
|
||||||
// strip the prefix if it exists so we can use the property name.
|
|
||||||
let keyName = jobIdField;
|
let keyName = jobIdField;
|
||||||
const prefix = "req.body.event.new.";
|
const prefix = "req.body.event.new.";
|
||||||
if (keyName.startsWith(prefix)) {
|
if (keyName.startsWith(prefix)) {
|
||||||
keyName = keyName.slice(prefix.length);
|
keyName = keyName.slice(prefix.length);
|
||||||
}
|
}
|
||||||
// Attempt to retrieve the job id from newData first; if not available, try oldData.
|
|
||||||
jobId = newData[keyName] || (oldData && oldData[keyName]) || null;
|
jobId = newData[keyName] || (oldData && oldData[keyName]) || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +1,115 @@
|
|||||||
const consoleDir = require("../utils/consoleDir");
|
|
||||||
const { getJobAssignmentType } = require("./stringHelpers");
|
const { getJobAssignmentType } = require("./stringHelpers");
|
||||||
|
|
||||||
|
// Helper function to populate watchers for app, fcm, and email channels
|
||||||
|
const populateWatchers = (data, result) => {
|
||||||
|
data.scenarioWatchers.forEach((recipients) => {
|
||||||
|
const { user, app, fcm, email } = recipients;
|
||||||
|
if (app === true) result.app.recipients.push({ user, bodyShopId: data.bodyShopId });
|
||||||
|
if (fcm === true) result.fcm.recipients.push(user);
|
||||||
|
if (email === true) result.email.recipients.push({ user });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const alternateTransportChangedBuilder = (data) => {
|
const alternateTransportChangedBuilder = (data) => {
|
||||||
consoleDir(data);
|
const result = {
|
||||||
|
jobId: data.jobId,
|
||||||
|
bodyShopName: data.bodyShopName,
|
||||||
|
app: {
|
||||||
|
key: "notifications.job.alternateTransportChanged",
|
||||||
|
variables: {
|
||||||
|
alternateTransport: data.data.alt_transport,
|
||||||
|
oldAlternateTransport: data.changedFields.alt_transport?.old
|
||||||
|
},
|
||||||
|
recipients: []
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
subject: `Alternate transport for ${data?.jobRoNumber} (${data.bodyShopName}) changed to ${data.data.alt_transport || "None"}`,
|
||||||
|
body: `The alternate transport status has been updated for job ${data?.jobRoNumber} in ${data.bodyShopName}.`,
|
||||||
|
recipients: []
|
||||||
|
},
|
||||||
|
fcm: { recipients: [] }
|
||||||
|
};
|
||||||
|
|
||||||
|
populateWatchers(data, result);
|
||||||
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
const billPostedHandler = (data) => {
|
const billPostedHandler = (data) => {
|
||||||
consoleDir(data);
|
const result = {
|
||||||
|
jobId: data.jobId,
|
||||||
|
bodyShopName: data.bodyShopName,
|
||||||
|
app: {
|
||||||
|
key: "notifications.job.billPosted",
|
||||||
|
variables: {
|
||||||
|
clmTotal: data.data.clm_total
|
||||||
|
},
|
||||||
|
recipients: []
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
subject: `Bill posted for ${data?.jobRoNumber} (${data.bodyShopName})`,
|
||||||
|
body: `A bill of $${data.data.clm_total} has been posted for job ${data?.jobRoNumber} in ${data.bodyShopName}.`,
|
||||||
|
recipients: []
|
||||||
|
},
|
||||||
|
fcm: { recipients: [] }
|
||||||
|
};
|
||||||
|
|
||||||
|
populateWatchers(data, result);
|
||||||
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
const criticalPartsStatusChangedBuilder = (data) => {
|
const criticalPartsStatusChangedBuilder = (data) => {
|
||||||
consoleDir(data);
|
const result = {
|
||||||
|
jobId: data.jobId,
|
||||||
|
bodyShopName: data.bodyShopName,
|
||||||
|
app: {
|
||||||
|
key: "notifications.job.criticalPartsStatusChanged",
|
||||||
|
variables: {
|
||||||
|
queuedForParts: data.data.queued_for_parts,
|
||||||
|
oldQueuedForParts: data.changedFields.queued_for_parts?.old
|
||||||
|
},
|
||||||
|
recipients: []
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
subject: `Critical parts status for ${data?.jobRoNumber} (${data.bodyShopName}) updated`,
|
||||||
|
body: `The critical parts status for job ${data?.jobRoNumber} in ${data.bodyShopName} has changed to ${data.data.queued_for_parts ? "queued" : "not queued"}.`,
|
||||||
|
recipients: []
|
||||||
|
},
|
||||||
|
fcm: { recipients: [] }
|
||||||
|
};
|
||||||
|
|
||||||
|
populateWatchers(data, result);
|
||||||
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
const intakeDeliveryChecklistCompletedBuilder = (data) => {
|
const intakeDeliveryChecklistCompletedBuilder = (data) => {
|
||||||
consoleDir(data);
|
const checklistType = data.changedFields.intakechecklist ? "intake" : "delivery";
|
||||||
|
const result = {
|
||||||
|
jobId: data.jobId,
|
||||||
|
bodyShopName: data.bodyShopName,
|
||||||
|
app: {
|
||||||
|
key: "notifications.job.checklistCompleted",
|
||||||
|
variables: {
|
||||||
|
checklistType,
|
||||||
|
completed: true
|
||||||
|
},
|
||||||
|
recipients: []
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
subject: `${checklistType.charAt(0).toUpperCase() + checklistType.slice(1)} checklist completed for ${data?.jobRoNumber} (${data.bodyShopName})`,
|
||||||
|
body: `The ${checklistType} checklist for job ${data?.jobRoNumber} in ${data.bodyShopName} has been completed.`,
|
||||||
|
recipients: []
|
||||||
|
},
|
||||||
|
fcm: { recipients: [] }
|
||||||
|
};
|
||||||
|
|
||||||
|
populateWatchers(data, result);
|
||||||
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
const jobAssignedToMeBuilder = (data) => {
|
const jobAssignedToMeBuilder = (data) => {
|
||||||
return {
|
const result = {
|
||||||
|
jobId: data.jobId,
|
||||||
|
bodyShopName: data.bodyShopName,
|
||||||
app: {
|
app: {
|
||||||
key: "notifications.job.assigned",
|
key: "notifications.job.assigned",
|
||||||
variables: {
|
variables: {
|
||||||
@@ -26,55 +117,252 @@ const jobAssignedToMeBuilder = (data) => {
|
|||||||
jobId: data.jobId,
|
jobId: data.jobId,
|
||||||
bodyShopName: data.bodyShopName
|
bodyShopName: data.bodyShopName
|
||||||
},
|
},
|
||||||
recipients: data.scenarioWatchers.map((watcher) => ({ email: watcher.user, employeeId: watcher.employeeId }))
|
recipients: []
|
||||||
},
|
},
|
||||||
email: {
|
email: {
|
||||||
subject: `You have been assigned to [${getJobAssignmentType(data.scenarioFields?.[0])}] on ${data?.jobRoNumber} in ${data.bodyShopName}`,
|
subject: `You have been assigned to [${getJobAssignmentType(data.scenarioFields?.[0])}] on ${data?.jobRoNumber} in ${data.bodyShopName}`,
|
||||||
body: `Hello, a new job has been assigned to you in ${data.bodyShopName}.`,
|
body: `Hello, a new job has been assigned to you in ${data.bodyShopName}.`,
|
||||||
recipient: data.scenarioWatchers.map((watcher) => watcher.user)
|
recipients: []
|
||||||
},
|
},
|
||||||
fcm: {}
|
fcm: { recipients: [] }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
populateWatchers(data, result);
|
||||||
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
const jobsAddedToProductionBuilder = (data) => {
|
const jobsAddedToProductionBuilder = (data) => {
|
||||||
consoleDir(data);
|
const result = {
|
||||||
|
jobId: data.jobId,
|
||||||
|
bodyShopName: data.bodyShopName,
|
||||||
|
app: {
|
||||||
|
key: "notifications.job.addedToProduction",
|
||||||
|
variables: {
|
||||||
|
inProduction: data.data.inproduction,
|
||||||
|
oldInProduction: data.changedFields.inproduction?.old
|
||||||
|
},
|
||||||
|
recipients: []
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
subject: `Job ${data?.jobRoNumber} (${data.bodyShopName}) added to production`,
|
||||||
|
body: `Job ${data?.jobRoNumber} in ${data.bodyShopName} has been added to production.`,
|
||||||
|
recipients: []
|
||||||
|
},
|
||||||
|
fcm: { recipients: [] }
|
||||||
|
};
|
||||||
|
|
||||||
|
populateWatchers(data, result);
|
||||||
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Verified
|
||||||
const jobStatusChangeBuilder = (data) => {
|
const jobStatusChangeBuilder = (data) => {
|
||||||
consoleDir(data);
|
const result = {
|
||||||
|
jobId: data.jobId,
|
||||||
|
bodyShopName: data.bodyShopName,
|
||||||
|
app: {
|
||||||
|
key: "notifications.job.statusChanged",
|
||||||
|
variables: {
|
||||||
|
status: data.data.status,
|
||||||
|
oldStatus: data.changedFields.status.old
|
||||||
|
},
|
||||||
|
recipients: []
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
subject: `The status of ${data?.jobRoNumber} (${data.bodyShopName}) has changed from ${data.changedFields.status.old} to ${data.data.status}`,
|
||||||
|
body: `...`,
|
||||||
|
recipients: []
|
||||||
|
},
|
||||||
|
fcm: { recipients: [] }
|
||||||
|
};
|
||||||
|
|
||||||
|
populateWatchers(data, result);
|
||||||
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
const newMediaAddedReassignedBuilder = (data) => {
|
const newMediaAddedReassignedBuilder = (data) => {
|
||||||
consoleDir(data);
|
const result = {
|
||||||
|
jobId: data.jobId,
|
||||||
|
bodyShopName: data.bodyShopName,
|
||||||
|
app: {
|
||||||
|
key: "notifications.job.newMediaAdded",
|
||||||
|
variables: {},
|
||||||
|
recipients: []
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
subject: `New media added to ${data?.jobRoNumber} (${data.bodyShopName})`,
|
||||||
|
body: `New media has been added to job ${data?.jobRoNumber} in ${data.bodyShopName}.`,
|
||||||
|
recipients: []
|
||||||
|
},
|
||||||
|
fcm: { recipients: [] }
|
||||||
|
};
|
||||||
|
|
||||||
|
populateWatchers(data, result);
|
||||||
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Verified
|
||||||
const newNoteAddedBuilder = (data) => {
|
const newNoteAddedBuilder = (data) => {
|
||||||
consoleDir(data);
|
const result = {
|
||||||
|
jobId: data.jobId,
|
||||||
|
bodyShopName: data.bodyShopName,
|
||||||
|
app: {
|
||||||
|
key: "notifications.job.newNoteAdded",
|
||||||
|
variables: {
|
||||||
|
text: data.data.text
|
||||||
|
},
|
||||||
|
recipients: []
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
subject: `New note added to ${data?.jobRoNumber} (${data.bodyShopName})`,
|
||||||
|
body: `A new note has been added to job ${data?.jobRoNumber} in ${data.bodyShopName}: "${data.data.text}"`,
|
||||||
|
recipients: []
|
||||||
|
},
|
||||||
|
fcm: { recipients: [] }
|
||||||
|
};
|
||||||
|
|
||||||
|
populateWatchers(data, result);
|
||||||
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
const newTimeTicketPostedBuilder = (data) => {
|
const newTimeTicketPostedBuilder = (data) => {
|
||||||
consoleDir(data);
|
const result = {
|
||||||
|
jobId: data.jobId,
|
||||||
|
bodyShopName: data.bodyShopName,
|
||||||
|
app: {
|
||||||
|
key: "notifications.job.newTimeTicketPosted",
|
||||||
|
variables: {},
|
||||||
|
recipients: []
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
subject: `New time ticket posted for ${data?.jobRoNumber} (${data.bodyShopName})`,
|
||||||
|
body: `A new time ticket has been posted for job ${data?.jobRoNumber} in ${data.bodyShopName}.`,
|
||||||
|
recipients: []
|
||||||
|
},
|
||||||
|
fcm: { recipients: [] }
|
||||||
|
};
|
||||||
|
|
||||||
|
populateWatchers(data, result);
|
||||||
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
const partMarkedBackOrderedBuilder = (data) => {
|
const partMarkedBackOrderedBuilder = (data) => {
|
||||||
consoleDir(data);
|
const result = {
|
||||||
|
jobId: data.jobId,
|
||||||
|
bodyShopName: data.bodyShopName,
|
||||||
|
app: {
|
||||||
|
key: "notifications.job.partBackOrdered",
|
||||||
|
variables: {
|
||||||
|
queuedForParts: data.data.queued_for_parts,
|
||||||
|
oldQueuedForParts: data.changedFields.queued_for_parts?.old
|
||||||
|
},
|
||||||
|
recipients: []
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
subject: `Part marked back-ordered for ${data?.jobRoNumber} (${data.bodyShopName})`,
|
||||||
|
body: `A part for job ${data?.jobRoNumber} in ${data.bodyShopName} has been marked as back-ordered.`,
|
||||||
|
recipients: []
|
||||||
|
},
|
||||||
|
fcm: { recipients: [] }
|
||||||
|
};
|
||||||
|
|
||||||
|
populateWatchers(data, result);
|
||||||
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
const paymentCollectedCompletedBuilder = (data) => {
|
const paymentCollectedCompletedBuilder = (data) => {
|
||||||
consoleDir(data);
|
const result = {
|
||||||
|
jobId: data.jobId,
|
||||||
|
bodyShopName: data.bodyShopName,
|
||||||
|
app: {
|
||||||
|
key: "notifications.job.paymentCollected",
|
||||||
|
variables: {
|
||||||
|
clmTotal: data.data.clm_total
|
||||||
|
},
|
||||||
|
recipients: []
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
subject: `Payment collected for ${data?.jobRoNumber} (${data.bodyShopName})`,
|
||||||
|
body: `Payment of $${data.data.clm_total} has been collected for job ${data?.jobRoNumber} in ${data.bodyShopName}.`,
|
||||||
|
recipients: []
|
||||||
|
},
|
||||||
|
fcm: { recipients: [] }
|
||||||
|
};
|
||||||
|
|
||||||
|
populateWatchers(data, result);
|
||||||
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
const scheduledDatesChangedBuilder = (data) => {
|
const scheduledDatesChangedBuilder = (data) => {
|
||||||
consoleDir(data);
|
const result = {
|
||||||
|
jobId: data.jobId,
|
||||||
|
bodyShopName: data.bodyShopName,
|
||||||
|
app: {
|
||||||
|
key: "notifications.job.scheduledDatesChanged",
|
||||||
|
variables: {
|
||||||
|
scheduledIn: data.data.scheduled_in,
|
||||||
|
oldScheduledIn: data.changedFields.scheduled_in?.old,
|
||||||
|
scheduledCompletion: data.data.scheduled_completion,
|
||||||
|
oldScheduledCompletion: data.changedFields.scheduled_completion?.old,
|
||||||
|
scheduledDelivery: data.data.scheduled_delivery,
|
||||||
|
oldScheduledDelivery: data.changedFields.scheduled_delivery?.old
|
||||||
|
},
|
||||||
|
recipients: []
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
subject: `Scheduled dates updated for ${data?.jobRoNumber} (${data.bodyShopName})`,
|
||||||
|
body: `Scheduled dates for job ${data?.jobRoNumber} in ${data.bodyShopName} have been updated.`,
|
||||||
|
recipients: []
|
||||||
|
},
|
||||||
|
fcm: { recipients: [] }
|
||||||
|
};
|
||||||
|
|
||||||
|
populateWatchers(data, result);
|
||||||
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
const supplementImportedBuilder = (data) => {
|
const supplementImportedBuilder = (data) => {
|
||||||
consoleDir(data);
|
const result = {
|
||||||
|
jobId: data.jobId,
|
||||||
|
bodyShopName: data.bodyShopName,
|
||||||
|
app: {
|
||||||
|
key: "notifications.job.supplementImported",
|
||||||
|
variables: {
|
||||||
|
suppAmt: data.data.cieca_ttl?.data?.supp_amt
|
||||||
|
},
|
||||||
|
recipients: []
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
subject: `Supplement imported for ${data?.jobRoNumber} (${data.bodyShopName})`,
|
||||||
|
body: `A supplement of $${data.data.cieca_ttl?.data?.supp_amt || 0} has been imported for job ${data?.jobRoNumber} in ${data.bodyShopName}.`,
|
||||||
|
recipients: []
|
||||||
|
},
|
||||||
|
fcm: { recipients: [] }
|
||||||
|
};
|
||||||
|
|
||||||
|
populateWatchers(data, result);
|
||||||
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
const tasksUpdatedCreatedBuilder = async (data) => {
|
const tasksUpdatedCreatedBuilder = (data) => {
|
||||||
consoleDir(data);
|
const result = {
|
||||||
|
jobId: data.jobId,
|
||||||
|
bodyShopName: data.bodyShopName,
|
||||||
|
app: {
|
||||||
|
key: "notifications.job.tasksUpdated",
|
||||||
|
variables: {},
|
||||||
|
recipients: []
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
subject: `Tasks ${data.isNew ? "created" : "updated"} for ${data?.jobRoNumber} (${data.bodyShopName})`,
|
||||||
|
body: `Tasks for job ${data?.jobRoNumber} in ${data.bodyShopName} have been ${data.isNew ? "created" : "updated"}.`,
|
||||||
|
recipients: []
|
||||||
|
},
|
||||||
|
fcm: { recipients: [] }
|
||||||
|
};
|
||||||
|
|
||||||
|
populateWatchers(data, result);
|
||||||
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ const queries = require("../graphql-client/queries");
|
|||||||
const { isEmpty, isFunction } = require("lodash");
|
const { isEmpty, isFunction } = require("lodash");
|
||||||
const { getMatchingScenarios } = require("./scenarioMapperr");
|
const { getMatchingScenarios } = require("./scenarioMapperr");
|
||||||
const emailQueue = require("./queues/emailQueue");
|
const emailQueue = require("./queues/emailQueue");
|
||||||
|
const consoleDir = require("../utils/consoleDir");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses an event and determines matching scenarios for notifications.
|
* Parses an event and determines matching scenarios for notifications.
|
||||||
@@ -209,11 +210,12 @@ const scenarioParser = async (req, jobIdField) => {
|
|||||||
// Step 9: Dispatch Email Notifications to the Email Notification Queue
|
// Step 9: Dispatch Email Notifications to the Email Notification Queue
|
||||||
// console.log(`8`);
|
// console.log(`8`);
|
||||||
|
|
||||||
const emailsToDispatch = scenariosToDispatch.map((scenario) => scenario.email);
|
const emailsToDispatch = scenariosToDispatch.map((scenario) => scenario?.email);
|
||||||
|
|
||||||
// Step 10: Dispatch App Notifications to the App Notification Queue
|
// Step 10: Dispatch App Notifications to the App Notification Queue
|
||||||
const appsToDispatch = scenariosToDispatch.map((scenario) => scenario.app);
|
const appsToDispatch = scenariosToDispatch.map((scenario) => scenario?.app);
|
||||||
|
|
||||||
|
consoleDir({ emailsToDispatch, appsToDispatch });
|
||||||
// TODO: Test Code for Queues
|
// TODO: Test Code for Queues
|
||||||
// emailQueue().add("test", { data: "test" });
|
// emailQueue().add("test", { data: "test" });
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user