feature/IO-3096-GlobalNotifications - Check-point
This commit is contained in:
@@ -1,34 +1,9 @@
|
||||
const changeParser = require("../utils/changeParser");
|
||||
const { hasScenarios } = require("../utils/scenarioMapperr");
|
||||
const scenarioParser = require("../utils/scenarioParser");
|
||||
|
||||
const handleTasksChange = async (req, res) => {
|
||||
try {
|
||||
// Step 1: Parse the changes
|
||||
const changes = await changeParser({
|
||||
newData: req?.body?.event?.data?.new,
|
||||
oldData: req?.body?.event?.data?.old,
|
||||
trigger: req?.body?.trigger,
|
||||
table: req?.body?.table
|
||||
});
|
||||
|
||||
console.dir(changes, { depth: null });
|
||||
|
||||
const scenarios = hasScenarios({
|
||||
table: changes.table.name,
|
||||
keys: changes.changedFieldNames,
|
||||
onNew: changes.isNew
|
||||
});
|
||||
|
||||
console.dir(scenarios, { depth: null });
|
||||
// Step 2: See if any scenarios match the changes
|
||||
// Step 3: Handle the scenario
|
||||
} catch (error) {
|
||||
console.error("Error handling tasks change:", error);
|
||||
return res.status(500).json({ message: "Error handling tasks change." });
|
||||
}
|
||||
|
||||
// Get Bodyshop from hasura user id,
|
||||
|
||||
return res.status(200).json({ message: "Tasks change handled." });
|
||||
const { logger } = req;
|
||||
scenarioParser(req).catch((e) => logger.log("notifications-error", "error", "jsr", null, { error: e?.message }));
|
||||
return res.status(200).json({ message: "Notification Scenario Event Handled." });
|
||||
};
|
||||
//
|
||||
module.exports = handleTasksChange;
|
||||
|
||||
Reference in New Issue
Block a user