provide default empty notification array

This commit is contained in:
Alex Holliday committed 2025-05-06 11:05:13 -07:00
1 parent 4bc9f59d80
commit 83e1cb0304
1 file changed
+1 -3
+1 -3
View File
@@ -538,14 +538,12 @@ class MonitorController {
const monitorBeforeEdit = await this.db.getMonitorById(monitorId); const monitorBeforeEdit = await this.db.getMonitorById(monitorId);
// Get notifications from the request body // Get notifications from the request body
const notifications = req.body.notifications; const notifications = req.body.notifications ?? [];
const editedMonitor = await this.db.editMonitor(monitorId, req.body); const editedMonitor = await this.db.editMonitor(monitorId, req.body);
await this.db.deleteNotificationsByMonitorId(editedMonitor._id); await this.db.deleteNotificationsByMonitorId(editedMonitor._id);
await Promise.all( await Promise.all(
notifications &&
notifications.map(async (notification) => { notifications.map(async (notification) => {
notification.monitorId = editedMonitor._id; notification.monitorId = editedMonitor._id;
await this.db.createNotification(notification); await this.db.createNotification(notification);