From 2d1e4615102c725964b99834cedae0d390450977 Mon Sep 17 00:00:00 2001 From: ROSHAN GARG Date: Wed, 7 Aug 2024 11:32:27 +0530 Subject: [PATCH] updated and added notification section --- resources/KYC/KycController.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/resources/KYC/KycController.js b/resources/KYC/KycController.js index c4f53c4..b0518d2 100644 --- a/resources/KYC/KycController.js +++ b/resources/KYC/KycController.js @@ -201,6 +201,16 @@ export const updateKycStatus = async (req, res) => { return res.status(403).json({ message: "Access denied" }); } + if (status === "reject") { + await rejectKYC(req.user._id, rejectionReason); + await Notification.create({ + title: "KYC Rejected", + msg: rejectionReason, + kyc_ref: kyc._id, + added_for: req.user._id, + userType: req.userType, + }); + } // Update the status if (status) { kyc.status = status; @@ -209,7 +219,7 @@ export const updateKycStatus = async (req, res) => { // Add rejection reason to notes if status is reject if (kyc.status === "reject" || status === "reject") { // kyc.rejection_reason = rejectionReason; - await rejectKYC(req.user._id, rejectionReason); + kyc.notes.push({ message: rejectionReason, user: user,