mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-01-20 16:49:46 -06:00
Merge pull request #1076 from bluewave-labs/fix/be/revert-noitification-refactor
fix/be/revert-notification-refactor
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user