add controller method

This commit is contained in:
Alex Holliday committed 2025-06-16 12:16:52 +08:00
1 parent bc3801edc0
commit 3cdc21f1be
2 files changed
+16 -3

No files matched your search

@@ -193,6 +193,22 @@ class NotificationController {
next(handleError(error, SERVICE_NAME, "editNotification"));
}
};
testAllNotifications = async (req, res, next) => {
try {
const { monitorId } = req.body;
const monitor = await this.db.getMonitorById(monitorId);
const notifications = monitor.notifications;
if (notifications.length === 0) throw new Error("No notifications");
const result = await this.notificationService.testAllNotifications(notifications);
if (!result) throw new Error("Failed to send all notifications");
return res.success({
msg: "All notifications sent successfully",
});
} catch (error) {
next(handleError(error, SERVICE_NAME, "testAllNotifications"));
}
};
}
export default NotificationController;