mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-01-08 18:59:43 -06:00
add controller method
This commit is contained in:
@@ -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";
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user