From a020a28993e2dd13a58bfff0a0b18432c951ff2f Mon Sep 17 00:00:00 2001 From: Mayank Mishra Date: Mon, 8 Dec 2025 17:31:55 +0530 Subject: [PATCH] Update host application handlers to retrieve user details using hostXid instead of userInfo.id for accurate email notifications. --- .../handlers/hosthub/hosts/acceptHostApplication.ts | 2 +- .../handlers/hosthub/hosts/rejectHostApplicationAM.ts | 2 +- .../handlers/hosthub/onboarding/rejectHostApplication.ts | 2 +- src/modules/minglaradmin/services/minglar.service.ts | 8 ++++++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/modules/minglaradmin/handlers/hosthub/hosts/acceptHostApplication.ts b/src/modules/minglaradmin/handlers/hosthub/hosts/acceptHostApplication.ts index 264949e..803d32d 100644 --- a/src/modules/minglaradmin/handlers/hosthub/hosts/acceptHostApplication.ts +++ b/src/modules/minglaradmin/handlers/hosthub/hosts/acceptHostApplication.ts @@ -46,7 +46,7 @@ export const handler = safeHandler(async ( // Add suggestion using service await minglarService.acceptHostApplication(hostXid, userInfo.id); - const hostDetails = await minglarService.getUserDetails(userInfo.id) + const hostDetails = await minglarService.getUserDetails(hostXid) await sendEmailToHostForApprovedApplication(hostDetails.emailAddress) return { diff --git a/src/modules/minglaradmin/handlers/hosthub/hosts/rejectHostApplicationAM.ts b/src/modules/minglaradmin/handlers/hosthub/hosts/rejectHostApplicationAM.ts index 6b9eacb..2539f75 100644 --- a/src/modules/minglaradmin/handlers/hosthub/hosts/rejectHostApplicationAM.ts +++ b/src/modules/minglaradmin/handlers/hosthub/hosts/rejectHostApplicationAM.ts @@ -46,7 +46,7 @@ export const handler = safeHandler(async ( // Add suggestion using service await minglarService.rejectHostApplicationAM(hostXid, userInfo.id); - const hostDetails = await minglarService.getUserDetails(userInfo.id) + const hostDetails = await minglarService.getUserDetails(hostXid) await sendAMRejectionMailtoHost(hostDetails.emailAddress) return { diff --git a/src/modules/minglaradmin/handlers/hosthub/onboarding/rejectHostApplication.ts b/src/modules/minglaradmin/handlers/hosthub/onboarding/rejectHostApplication.ts index a1b145c..8a5f80c 100644 --- a/src/modules/minglaradmin/handlers/hosthub/onboarding/rejectHostApplication.ts +++ b/src/modules/minglaradmin/handlers/hosthub/onboarding/rejectHostApplication.ts @@ -46,7 +46,7 @@ export const handler = safeHandler(async ( // Add suggestion using service await minglarService.rejectHostApplication(hostXid, userInfo.id); - const hostDetails = await minglarService.getUserDetails(userInfo.id) + const hostDetails = await minglarService.getUserDetails(hostXid) if (!hostDetails?.emailAddress) { throw new ApiError(404, 'Host details or email address not found'); } diff --git a/src/modules/minglaradmin/services/minglar.service.ts b/src/modules/minglaradmin/services/minglar.service.ts index 3ca7c01..19f1153 100644 --- a/src/modules/minglaradmin/services/minglar.service.ts +++ b/src/modules/minglaradmin/services/minglar.service.ts @@ -137,9 +137,13 @@ export class MinglarService { } async getUserDetails(id: number) { - return await this.prisma.user.findUnique({ - where: { id: id }, + const hostDetail = await this.prisma.hostHeader.findFirst({ + where: { id: id } + }) + const userDetails = await this.prisma.user.findUnique({ + where: { id: hostDetail.userXid }, }); + return userDetails; } async verifyHostOtp(email: string, otp: string): Promise {