From 5eca40c00042803e27f29267a8f64be19524f0fb Mon Sep 17 00:00:00 2001 From: MatejMa2ur Date: Sun, 10 Nov 2024 13:38:51 +0100 Subject: [PATCH] fix: ensure correct hackathonId for application review Update getApplicationIdForReview to validate hackathonId for reviewing applications. This ensures that only applications from the current hackathon are fetched and processed correctly. --- .../getApplicationIdForReview.ts | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/server/getters/dashboard/applicationReview/getApplicationIdForReview.ts b/src/server/getters/dashboard/applicationReview/getApplicationIdForReview.ts index 9844c27..740cc94 100644 --- a/src/server/getters/dashboard/applicationReview/getApplicationIdForReview.ts +++ b/src/server/getters/dashboard/applicationReview/getApplicationIdForReview.ts @@ -51,10 +51,28 @@ const getApplicationIdForReview = async ( }); if (currentApplicationForReviewId) { - return { - totalApplicationsLeftToReviewCount: applications.length, - applicationId: currentApplicationForReviewId, - }; + // Fetch the current application for review + const currentApplicationForReview = await prisma.application.findUnique({ + where: { + id: currentApplicationForReviewId, + }, + select: { + hacker: { + select: { + hackathonId: true, + }, + }, + }, + }); + if ( + currentApplicationForReview && + currentApplicationForReview.hacker.hackathonId === hackathonId + ) { + return { + totalApplicationsLeftToReviewCount: applications.length, + applicationId: currentApplicationForReviewId, + }; + } } if (applications.length === 0) {