Skip to content

Scheduling infrastructure for absolutely everyone.

fix: Booking Cancelled Webhook - Organiser webhook payload is missing id. #14697 (#14745)

Vikas Patil8deedfd36146
diff --git a/apps/web/test/utils/bookingScenario/expects.ts b/apps/web/test/utils/bookingScenario/expects.ts
index c01bc1745ea..3600a4adca4 100644
--- a/apps/web/test/utils/bookingScenario/expects.ts
+++ b/apps/web/test/utils/bookingScenario/expects.ts
@@ -975,6 +975,44 @@ export function expectBookingRescheduledWebhookToHaveBeenFired({
});
}
+export function expectBookingCancelledWebhookToHaveBeenFired({
+ booker,
+ location,
+ subscriberUrl,
+ payload,
+}: {
+ organizer: { email: string; name: string };
+ booker: { email: string; name: string };
+ subscriberUrl: string;
+ location: string;
+ payload?: Record<string, unknown>;
+}) {
+ expectWebhookToHaveBeenCalledWith(subscriberUrl, {
+ triggerEvent: "BOOKING_CANCELLED",
+ payload: {
+ ...payload,
+ metadata: null,
+ responses: {
+ booker: {
+ label: "your_name",
+ value: booker.name,
+ isHidden: false,
+ },
+ email: {
+ label: "email_address",
+ value: booker.email,
+ isHidden: false,
+ },
+ location: {
+ label: "location",
+ value: { optionValue: "", value: location },
+ isHidden: false,
+ },
+ },
+ },
+ });
+}
+
export function expectBookingPaymentIntiatedWebhookToHaveBeenFired({
booker,
location,
diff --git a/packages/features/bookings/lib/handleCancelBooking.ts b/packages/features/bookings/lib/handleCancelBooking.ts
index a368fea9960..49d8ae7f5dd 100644
--- a/packages/features/bookings/lib/handleCancelBooking.ts
+++ b/packages/features/bookings/lib/handleCancelBooking.ts
@@ -200,6 +200,8 @@ async function handler(req: CustomRequest) {
id: bookingToDelete.userId,
},
select: {
+ id: true,
+ username:true,
name: true,
email: true,
timeZone: true,
@@ -255,6 +257,8 @@ async function handler(req: CustomRequest) {
startTime: bookingToDelete?.startTime ? dayjs(bookingToDelete.startTime).format() : "",
endTime: bookingToDelete?.endTime ? dayjs(bookingToDelete.endTime).format() : "",
organizer: {
+ id: organizer.id,
+ username: organizer.username || undefined,
email: bookingToDelete?.userPrimaryEmail ?? organizer.email,
name: organizer.name ?? "Nameless",
timeZone: organizer.timeZone,
@@ -272,8 +276,8 @@ async function handler(req: CustomRequest) {
destinationCalendar: bookingToDelete?.destinationCalendar
? [bookingToDelete?.destinationCalendar]
: bookingToDelete?.user.destinationCalendar
- ? [bookingToDelete?.user.destinationCalendar]
- : [],
+ ? [bookingToDelete?.user.destinationCalendar]
+ : [],
cancellationReason: cancellationReason,
...(teamMembers && {
team: { name: bookingToDelete?.eventType?.team?.name || "Nameless", members: teamMembers, id: teamId! },