fix(daily-webhook): use BookingRepository instead of direct prisma call (#29541)

This commit is contained in:
Bryan Varela
2026-06-16 12:34:18 +00:00
committed by GitHub
parent 70a883b191
commit 561cf889ab
2 changed files with 37 additions and 32 deletions
+4 -32
View File
@@ -1,42 +1,14 @@
import { BookingRepository } from "@calcom/features/bookings/repositories/BookingRepository";
import { HttpError } from "@calcom/lib/http-error";
import logger from "@calcom/lib/logger";
import { safeStringify } from "@calcom/lib/safeStringify";
import prisma, { bookingMinimalSelect } from "@calcom/prisma";
import prisma from "@calcom/prisma";
const log = logger.getSubLogger({ prefix: ["daily-video-webhook-handler"] });
// TODO: use BookingRepository
export const getBooking = async (bookingId: number) => {
const booking = await prisma.booking.findUniqueOrThrow({
where: {
id: bookingId,
},
select: {
...bookingMinimalSelect,
uid: true,
location: true,
isRecorded: true,
eventTypeId: true,
eventType: {
select: {
teamId: true,
parentId: true,
canSendCalVideoTranscriptionEmails: true,
customReplyToEmail: true,
},
},
user: {
select: {
id: true,
timeZone: true,
email: true,
name: true,
locale: true,
destinationCalendar: true,
},
},
},
});
const bookingRepository = new BookingRepository(prisma);
const booking = await bookingRepository.findByIdWithUserAndEventType(bookingId);
if (!booking) {
log.error(
@@ -2137,4 +2137,37 @@ export class BookingRepository implements IBookingRepository {
},
});
}
async findByIdWithUserAndEventType(bookingId: number) {
return await this.prismaClient.booking.findUnique({
where: {
id: bookingId,
},
select: {
...bookingMinimalSelect,
uid: true,
location: true,
isRecorded: true,
eventTypeId: true,
eventType: {
select: {
teamId: true,
parentId: true,
canSendCalVideoTranscriptionEmails: true,
customReplyToEmail: true,
},
},
user: {
select: {
id: true,
timeZone: true,
email: true,
name: true,
locale: true,
destinationCalendar: true,
},
},
},
});
}
}