diff --git a/server/controllers/monitorController.js b/server/controllers/monitorController.js index 228eabbb0..6c6136fb5 100755 --- a/server/controllers/monitorController.js +++ b/server/controllers/monitorController.js @@ -1,4 +1,3 @@ -import Monitor from "../db/models/Monitor.js"; import { getMonitorByIdParamValidation, getMonitorByIdQueryValidation, @@ -16,8 +15,6 @@ import { getHardwareDetailsByIdQueryValidation, } from "../validation/joi.js"; import sslChecker from "ssl-checker"; -import jwt from "jsonwebtoken"; -import { getTokenFromHeaders } from "../utils/utils.js"; import logger from "../utils/logger.js"; import { handleError, handleValidationError } from "./controllerUtils.js"; import axios from "axios"; diff --git a/server/controllers/notificationController.js b/server/controllers/notificationController.js index a9c399901..c9da011f0 100755 --- a/server/controllers/notificationController.js +++ b/server/controllers/notificationController.js @@ -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;