Merge pull request #506 from bluewave-labs/fix/be/create-monitor-unsafe-access
Fix/be/create monitor unsafe access
This commit is contained in:
1 file changed
+8
-7
@@ -134,13 +134,14 @@ 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);
|
||||||
|
|
||||||
await Promise.all(
|
if (notifications && notifications.length !== 0) {
|
||||||
notifications.map(async (notification) => {
|
await Promise.all(
|
||||||
notification.monitorId = monitor._id;
|
notifications.map(async (notification) => {
|
||||||
await req.db.createNotification(notification);
|
notification.monitorId = monitor._id;
|
||||||
})
|
await req.db.createNotification(notification);
|
||||||
);
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
// Add monitor to job queue
|
// Add monitor to job queue
|
||||||
req.jobQueue.addJob(monitor._id, monitor);
|
req.jobQueue.addJob(monitor._id, monitor);
|
||||||
return res.status(201).json({
|
return res.status(201).json({
|
||||||
|
|||||||
Reference in new issue
Block a user