Merge pull request #1076 from bluewave-labs/fix/be/revert-noitification-refactor

fix/be/revert-notification-refactor
This commit is contained in:
Alexander Holliday
2024-10-26 18:47:02 +08:00
committed by GitHub
2 changed files with 7 additions and 6 deletions

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);

View File

@@ -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({