IO-2924-Refactor-Production-board-to-use-Socket-Provider: Finalize

Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
Dave Richer
2024-09-26 10:56:48 -04:00
parent 328a64eb90
commit 932f572fb5
7 changed files with 127 additions and 89 deletions

View File

@@ -1,7 +1,7 @@
const { isObject } = require("lodash");
const jobUpdated = async (req, res) => {
const { ioRedis, logger } = req;
const { ioRedis, logger, ioHelpers } = req;
if (!req?.body?.event?.data?.new || !isObject(req?.body?.event?.data?.new)) {
logger.log("job-update-error", "ERROR", req.user?.email, null, {
@@ -24,8 +24,7 @@ const jobUpdated = async (req, res) => {
const bodyshopID = updatedJob.shopid;
// Emit the job-updated event only to the room corresponding to the bodyshop
ioRedis.to(bodyshopID).emit("job-updated", updatedJob);
ioRedis.to(ioHelpers.getBodyshopRoom(bodyshopID)).emit("job-updated", updatedJob);
return res.json({ message: "Job updated and event emitted" });
};