add controller method
This commit is contained in:
1 parent
bc3801edc0
commit
3cdc21f1be
2 files changed
+16
-3
No files matched your search
@@ -1,4 +1,3 @@
|
|||||||
import Monitor from "../db/models/Monitor.js";
|
|
||||||
import {
|
import {
|
||||||
getMonitorByIdParamValidation,
|
getMonitorByIdParamValidation,
|
||||||
getMonitorByIdQueryValidation,
|
getMonitorByIdQueryValidation,
|
||||||
@@ -16,8 +15,6 @@ import {
|
|||||||
getHardwareDetailsByIdQueryValidation,
|
getHardwareDetailsByIdQueryValidation,
|
||||||
} from "../validation/joi.js";
|
} from "../validation/joi.js";
|
||||||
import sslChecker from "ssl-checker";
|
import sslChecker from "ssl-checker";
|
||||||
import jwt from "jsonwebtoken";
|
|
||||||
import { getTokenFromHeaders } from "../utils/utils.js";
|
|
||||||
import logger from "../utils/logger.js";
|
import logger from "../utils/logger.js";
|
||||||
import { handleError, handleValidationError } from "./controllerUtils.js";
|
import { handleError, handleValidationError } from "./controllerUtils.js";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
|||||||
@@ -193,6 +193,22 @@ class NotificationController {
|
|||||||
next(handleError(error, SERVICE_NAME, "editNotification"));
|
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;
|
export default NotificationController;
|
||||||
Reference in new issue
Block a user