From 8007daa66bfcc1b3ddd5fa7fab0fa432b9cbeb33 Mon Sep 17 00:00:00 2001 From: Skorpios Date: Wed, 12 Feb 2025 19:16:20 -0800 Subject: [PATCH] Used response handling middleware for the response format. --- Server/controllers/notificationController.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Server/controllers/notificationController.js b/Server/controllers/notificationController.js index 6f28579ff..e202c5274 100644 --- a/Server/controllers/notificationController.js +++ b/Server/controllers/notificationController.js @@ -15,13 +15,18 @@ class NotificationController { statusChanged: true, prevStatus: true, }; + if (type === "webhook") { await this.notificationService.sendWebhookNotification( networkResponse, config ); } - res.json({ success: true, msg: "Notification sent successfully" }); + + return res.success({ + msg: "Notification sent successfully" + }); + } catch (error) { logger.error({ message: error.message, @@ -29,7 +34,10 @@ class NotificationController { method: "triggerNotification", stack: error.stack, }); - res.status(500).json({ success: false, msg: "Failed to send notification" }); + + return res.error({ + msg: "Failed to send notification" + }); } } }