Revert moving notification check to validation, FE always sends an empty notification array

This commit is contained in:
Alex Holliday
2024-10-26 18:45:51 +08:00
parent d8480b2548
commit fa5eef14c3
2 changed files with 7 additions and 6 deletions
+6 -5
View File
@@ -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);