release/2024-11-01 - Update Trigger for job_updated - Make the callback work with old and new Hasura
Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
@@ -2,7 +2,15 @@ const { isObject } = require("lodash");
|
||||
|
||||
const jobUpdated = async (req, res) => {
|
||||
const { ioRedis, logger, ioHelpers } = req;
|
||||
// Old Way
|
||||
if (req?.body?.event?.data?.new || isObject(req?.body?.event?.data?.new)) {
|
||||
const updatedJob = req.body.event.data.new;
|
||||
const bodyshopID = updatedJob.shopid;
|
||||
ioRedis.to(ioHelpers.getBodyshopRoom(bodyshopID)).emit("production-job-updated", updatedJob);
|
||||
return res.json({ message: "Job updated and event emitted" });
|
||||
}
|
||||
|
||||
// New way
|
||||
if (!req?.body?.data || !isObject(req.body.data)) {
|
||||
logger.log("job-update-error", "ERROR", req.user?.email, null, {
|
||||
message: `Malformed Job Update request sent from Hasura`,
|
||||
|
||||
Reference in New Issue
Block a user