feature/IO-3291-Tasks-Notifications: Checkpoint

This commit is contained in:
Dave Richer
2025-07-10 16:40:55 -04:00
parent 1127864ba9
commit cf181dfd0a
2 changed files with 135 additions and 86 deletions

View File

@@ -146,17 +146,10 @@ const handlePaymentsChange = async (req, res) =>
processNotificationEvent(req, res, "req.body.event.new.jobid", "Payments Changed Notification Event Handled.");
/**
* Handle tasks change notifications.
*
* @param {Object} req - Express request object.
* @param {Object} res - Express response object.
* @returns {Promise<Object>} JSON response with a success message.
* Handle task socket emit.
* @param req
*/
const handleTasksChange = async (req, res) => {
console.log("Handling tasks change notification...!!!!!!!!!!!!");
// Handle Notification Event
processNotificationEvent(req, res, "req.body.event.new.jobid", "Tasks Notifications Event Handled.");
const handleTaskSocketEmit = (req) => {
const {
logger,
ioRedis,
@@ -184,7 +177,7 @@ const handleTasksChange = async (req, res) => {
if (newData.deleted && !oldData.deleted) {
type = "task-deleted";
taskData = { id: newData.id };
taskData = { id: newData.id, assigned_to: newData.assigned_to };
} else if (!newData.deleted && oldData.deleted) {
type = "task-created";
} else if (!newData.deleted) {
@@ -202,6 +195,21 @@ const handleTasksChange = async (req, res) => {
logger.log("tasks-event-missing-data", "error", "notifications", null, { bodyshopId, hasIo: !!ioRedis, type });
}
};
/**
* Handle tasks change notifications.
* Note: this also handles task center notifications.
*
* @param {Object} req - Express request object.
* @param {Object} res - Express response object.
* @returns {Promise<Object>} JSON response with a success message.
*/
const handleTasksChange = async (req, res) => {
// Handle Notification Event
processNotificationEvent(req, res, "req.body.event.new.jobid", "Tasks Notifications Event Handled.");
handleTaskSocketEmit(req);
};
/**
* Handle time tickets change notifications.
*