Revert moving notification check to validation, FE always sends an empty notification array
This commit is contained in:
1 parent
d8480b2548
commit
fa5eef14c3
2 files changed
+7
-6
No files matched your search
@@ -225,14 +225,15 @@ const createMonitor = async (req, res, next) => {
|
|||||||
const notifications = req.body.notifications;
|
const notifications = req.body.notifications;
|
||||||
const monitor = await req.db.createMonitor(req, res);
|
const monitor = await req.db.createMonitor(req, res);
|
||||||
|
|
||||||
monitor.notifications =
|
if (notifications && notifications.length > 0) {
|
||||||
notifications &&
|
monitor.notifications = await Promise.all(
|
||||||
(await Promise.all(
|
|
||||||
notifications.map(async (notification) => {
|
notifications.map(async (notification) => {
|
||||||
notification.monitorId = monitor._id;
|
notification.monitorId = monitor._id;
|
||||||
await req.db.createNotification(notification);
|
return await req.db.createNotification(notification);
|
||||||
})
|
})
|
||||||
));
|
);
|
||||||
|
}
|
||||||
|
|
||||||
await monitor.save();
|
await monitor.save();
|
||||||
// Add monitor to job queue
|
// Add monitor to job queue
|
||||||
req.jobQueue.addJob(monitor._id, monitor);
|
req.jobQueue.addJob(monitor._id, monitor);
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ const createMonitorBodyValidation = joi.object({
|
|||||||
usage_memory: joi.number(),
|
usage_memory: joi.number(),
|
||||||
usage_disk: joi.number(),
|
usage_disk: joi.number(),
|
||||||
}),
|
}),
|
||||||
notifications: joi.array().items(joi.object()).min(1),
|
notifications: joi.array().items(joi.object()),
|
||||||
});
|
});
|
||||||
|
|
||||||
const editMonitorBodyValidation = joi.object({
|
const editMonitorBodyValidation = joi.object({
|
||||||
|
|||||||
Reference in new issue
Block a user