Skip to content

Commit

Permalink
Merge pull request #1076 from bluewave-labs/fix/be/revert-noitificati…
Browse files Browse the repository at this point in the history
…on-refactor

fix/be/revert-notification-refactor
  • Loading branch information
ajhollid authored Oct 26, 2024
2 parents d8480b2 + fa5eef1 commit 86ab22d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions Server/controllers/monitorController.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,15 @@ const createMonitor = async (req, res, next) => {
const notifications = req.body.notifications;
const monitor = await req.db.createMonitor(req, res);

monitor.notifications =
notifications &&
(await Promise.all(
if (notifications && notifications.length > 0) {
monitor.notifications = await Promise.all(
notifications.map(async (notification) => {
notification.monitorId = monitor._id;
await req.db.createNotification(notification);
return await req.db.createNotification(notification);
})
));
);
}

await monitor.save();
// Add monitor to job queue
req.jobQueue.addJob(monitor._id, monitor);
Expand Down
2 changes: 1 addition & 1 deletion Server/validation/joi.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ const createMonitorBodyValidation = joi.object({
usage_memory: joi.number(),
usage_disk: joi.number(),
}),
notifications: joi.array().items(joi.object()).min(1),
notifications: joi.array().items(joi.object()),
});

const editMonitorBodyValidation = joi.object({
Expand Down

0 comments on commit 86ab22d

Please sign in to comment.