diff --git a/server/notifications/scenarioMapper.js b/server/notifications/scenarioMapper.js index c125f3952..27d290a66 100644 --- a/server/notifications/scenarioMapper.js +++ b/server/notifications/scenarioMapper.js @@ -30,10 +30,12 @@ const { isFunction } = require("lodash"); * - builder {Function}: A function to handle the scenario. * - onlyTruthyValues {boolean|Array}: Specifies fields that must have truthy values for the scenario to match. * - filterCallback {Function}: Optional callback (sync or async) to further filter the scenario based on event data (returns boolean). + * - enabled {boolean}: If true, the scenario is active; if false or omitted, the scenario is skipped. */ const notificationScenarios = [ { key: "job-assigned-to-me", + enabled: true, table: "jobs", fields: ["employee_prep", "employee_body", "employee_csr", "employee_refinish"], matchToUserFields: ["employee_prep", "employee_body", "employee_csr", "employee_refinish"], @@ -41,24 +43,28 @@ const notificationScenarios = [ }, { key: "bill-posted", + enabled: true, table: "bills", builder: billPostedHandler, onNew: true }, { key: "new-note-added", + enabled: true, table: "notes", builder: newNoteAddedBuilder, onNew: true }, { key: "schedule-dates-changed", + enabled: true, table: "jobs", fields: ["scheduled_in", "scheduled_completion", "scheduled_delivery"], builder: scheduledDatesChangedBuilder }, { key: "tasks-updated-created", + enabled: true, table: "tasks", fields: ["updated_at"], // onNew: true, @@ -66,12 +72,14 @@ const notificationScenarios = [ }, { key: "job-status-change", + enabled: true, table: "jobs", fields: ["status"], builder: jobStatusChangeBuilder }, { key: "job-added-to-production", + enabled: true, table: "jobs", fields: ["inproduction"], onlyTruthyValues: ["inproduction"], @@ -79,36 +87,42 @@ const notificationScenarios = [ }, { key: "alternate-transport-changed", + enabled: true, table: "jobs", fields: ["alt_transport"], builder: alternateTransportChangedBuilder }, { key: "new-time-ticket-posted", + enabled: true, table: "timetickets", builder: newTimeTicketPostedBuilder }, { key: "intake-delivery-checklist-completed", + enabled: true, table: "jobs", fields: ["intakechecklist", "deliverchecklist"], builder: intakeDeliveryChecklistCompletedBuilder }, { key: "payment-collected-completed", + enabled: true, table: "payments", onNew: true, builder: paymentCollectedCompletedBuilder }, { - // MAKE SURE YOU ARE NOT ON A LMS ENVIRONMENT + // Only works on a non LMS ENV key: "new-media-added-reassigned", + enabled: true, table: "documents", fields: ["jobid"], builder: newMediaAddedReassignedBuilder }, { key: "critical-parts-status-changed", + enabled: true, table: "joblines", fields: ["status"], onlyTruthyValues: ["status"], @@ -117,6 +131,7 @@ const notificationScenarios = [ }, { key: "part-marked-back-ordered", + enabled: true, table: "joblines", fields: ["status"], builder: partMarkedBackOrderedBuilder, @@ -133,12 +148,11 @@ const notificationScenarios = [ } } }, - // -------------- Difficult --------------- - // Holding off on this one for now + // Holding off on this one for now, spans multiple tables { key: "supplement-imported", + enabled: false, builder: supplementImportedBuilder - // spans multiple tables, } ]; @@ -159,6 +173,11 @@ const notificationScenarios = [ const getMatchingScenarios = async (eventData, getBodyshopFromRedis) => { const matches = []; for (const scenario of notificationScenarios) { + // Check if the scenario is enabled; skip if not explicitly true + if (scenario.enabled !== true) { + continue; + } + // If eventData has a table, then only scenarios with a table property that matches should be considered. if (eventData.table) { if (!scenario.table || eventData.table.name !== scenario.table) {