feature/IO-3225-Notifications-1.5: DB Changes

This commit is contained in:
Dave Richer
2025-05-05 15:02:44 -04:00
parent 2deb7fd520
commit 8109a12898
8 changed files with 292 additions and 20 deletions

View File

@@ -6,6 +6,7 @@
*/
const scenarioParser = require("./scenarioParser");
const { autoAddWatchers } = require("./autoAddWatchers"); // New module
/**
* Processes a notification event by invoking the scenario parser.
@@ -185,6 +186,27 @@ const handlePartsDispatchChange = (req, res) => res.status(200).json({ message:
*/
const handlePartsOrderChange = (req, res) => res.status(200).json({ message: "Parts Order change handled." });
/**
* Handle auto-add watchers for new jobs.
*
* @param {Object} req - Express request object.
* @param {Object} res - Express response object.
* @returns {Promise<Object>} JSON response with a success message.
*/
const handleAutoAddWatchers = async (req, res) => {
const { logger } = req;
// Call autoAddWatchers but don't await it; log any error that occurs.
autoAddWatchers(req).catch((error) => {
logger.log("auto-add-watchers-error", "error", "notifications", null, {
message: error?.message,
stack: error?.stack
});
});
return res.status(200).json({ message: "Auto-Add Watchers Event Handled." });
};
module.exports = {
handleJobsChange,
handleBillsChange,
@@ -195,5 +217,6 @@ module.exports = {
handlePartsOrderChange,
handlePaymentsChange,
handleTasksChange,
handleTimeTicketsChange
handleTimeTicketsChange,
handleAutoAddWatchers
};