Update host application handlers to retrieve user details using hostXid instead of userInfo.id for accurate email notifications.
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
@@ -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<boolean> {
|
||||
|
||||
Reference in New Issue
Block a user