diff --git a/packages/features/bookings/lib/handleConfirmation.ts b/packages/features/bookings/lib/handleConfirmation.ts index 35235757c965b9..15b9d5b983c47a 100644 --- a/packages/features/bookings/lib/handleConfirmation.ts +++ b/packages/features/bookings/lib/handleConfirmation.ts @@ -28,6 +28,7 @@ import { EventTypeMetaDataSchema, eventTypeAppMetadataOptionalSchema } from "@ca import { getAllWorkflowsFromEventType } from "@calcom/trpc/server/routers/viewer/workflows/util"; import type { AdditionalInformation, CalendarEvent } from "@calcom/types/Calendar"; +import { getCalEventResponses } from "./getCalEventResponses"; import { scheduleNoShowTriggers } from "./handleNewBooking/scheduleNoShowTriggers"; const log = logger.getSubLogger({ prefix: ["[handleConfirmation] book:user"] }); @@ -155,6 +156,8 @@ export async function handleConfirmation(args: { cancellationReason?: string | null; metadata: Prisma.JsonValue | null; customInputs: Prisma.JsonValue; + title: string; + responses: Prisma.JsonValue; eventType: { bookingFields: Prisma.JsonValue | null; slug: string; @@ -232,7 +235,9 @@ export async function handleConfirmation(args: { description: true, cancellationReason: true, attendees: true, + responses: true, location: true, + title: true, uid: true, startTime: true, metadata: true, @@ -292,6 +297,8 @@ export async function handleConfirmation(args: { }, uid: true, startTime: true, + responses: true, + title: true, metadata: true, cancellationReason: true, endTime: true, @@ -393,8 +400,18 @@ export async function handleConfirmation(args: { const scheduleTriggerPromises: Promise[] = []; + const updatedBookingsWithCalEventResponses = updatedBookings.map((booking) => { + return { + ...booking, + ...getCalEventResponses({ + bookingFields: booking.eventType?.bookingFields ?? null, + booking, + }), + }; + }); + subscribersMeetingStarted.forEach((subscriber) => { - updatedBookings.forEach((booking) => { + updatedBookingsWithCalEventResponses.forEach((booking) => { scheduleTriggerPromises.push( scheduleTrigger({ booking, @@ -406,7 +423,7 @@ export async function handleConfirmation(args: { }); }); subscribersMeetingEnded.forEach((subscriber) => { - updatedBookings.forEach((booking) => { + updatedBookingsWithCalEventResponses.forEach((booking) => { scheduleTriggerPromises.push( scheduleTrigger({ booking, diff --git a/packages/features/bookings/lib/handleNewBooking.ts b/packages/features/bookings/lib/handleNewBooking.ts index d7e1666f169c2f..f1e2a64077bcc4 100644 --- a/packages/features/bookings/lib/handleNewBooking.ts +++ b/packages/features/bookings/lib/handleNewBooking.ts @@ -1852,10 +1852,14 @@ async function handler( } if (booking && booking.status === BookingStatus.ACCEPTED) { + const bookingWithCalEventResponses = { + ...booking, + responses: reqBody.calEventResponses, + }; for (const subscriber of subscribersMeetingEnded) { scheduleTriggerPromises.push( scheduleTrigger({ - booking, + booking: bookingWithCalEventResponses, subscriberUrl: subscriber.subscriberUrl, subscriber, triggerEvent: WebhookTriggerEvents.MEETING_ENDED, @@ -1867,7 +1871,7 @@ async function handler( for (const subscriber of subscribersMeetingStarted) { scheduleTriggerPromises.push( scheduleTrigger({ - booking, + booking: bookingWithCalEventResponses, subscriberUrl: subscriber.subscriberUrl, subscriber, triggerEvent: WebhookTriggerEvents.MEETING_STARTED, diff --git a/packages/features/webhooks/lib/scheduleTrigger.ts b/packages/features/webhooks/lib/scheduleTrigger.ts index 65d7ffeea42040..2d7ba320a77aef 100644 --- a/packages/features/webhooks/lib/scheduleTrigger.ts +++ b/packages/features/webhooks/lib/scheduleTrigger.ts @@ -70,9 +70,32 @@ export async function addSubscription({ }, status: BookingStatus.ACCEPTED, }, + include: { + eventType: { + select: { + bookingFields: true, + }, + }, + attendees: { + select: { + name: true, + email: true, + }, + }, + }, + }); + + const bookingsWithCalEventResponses = bookings.map((booking) => { + return { + ...booking, + ...getCalEventResponses({ + bookingFields: booking.eventType?.bookingFields ?? null, + booking, + }), + }; }); - for (const booking of bookings) { + for (const booking of bookingsWithCalEventResponses) { scheduleTrigger({ booking, subscriberUrl: createSubscription.subscriberUrl,