Defined new schema for the config object.

This commit is contained in:
Skorpios committed 2025-02-16 19:32:52 -08:00
1 parent 07882e045b
commit 8409571d57
4 files changed
+66 -40

No files matched your search

+12 -7
View File
@@ -1,13 +1,12 @@
class NotificationController {
constructor(notificationService) {
this.notificationService = notificationService;
this.triggerNotification = this.triggerNotification.bind(this);
}
async triggerNotification(req, res, next) {
async triggerNotification(req, res, next) {
try {
const { monitorId, type, config } = req.body;
const { monitorId, type, platform, config } = req.body;
const networkResponse = {
monitor: { _id: monitorId, name: "Test Monitor", url: "http://www.google.com" },
@@ -15,18 +14,24 @@ class NotificationController {
statusChanged: true,
prevStatus: true,
};
if (type === "webhook") {
const notification = {
type,
platform,
config
};
await this.notificationService.sendWebhookNotification(
networkResponse,
config
notification
);
}
return res.success({
msg: "Notification sent successfully"
});
} catch (error) {
error.service = "NotificationController";
error.method = "triggerNotification";