Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 11 commits into from May 6, 2024
38 changes: 38 additions & 0 deletions apps/web/test/utils/bookingScenario/expects.ts
Expand Up @@ -170,7 +170,7 @@
pass: false,
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
actual: icsObject[icsKey].uid!,

Check warning on line 173 in apps/web/test/utils/bookingScenario/expects.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

apps/web/test/utils/bookingScenario/expects.ts#L173

[@typescript-eslint/no-non-null-assertion] Forbidden non-null assertion.
expected: expectedEmail.ics?.iCalUID,
message: () => `Expected ICS UID ${isNot ? "is" : "isn't"} present in actual`,
};
Expand Down Expand Up @@ -386,7 +386,7 @@
uid: booking.uid,
},
include: {
references: true,

Check warning on line 389 in apps/web/test/utils/bookingScenario/expects.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

apps/web/test/utils/bookingScenario/expects.ts#L389

[@calcom/eslint/no-prisma-include-true] Do not pass argument object with include: { AnyPropertyName: true } to prisma methods
},
});

Expand Down Expand Up @@ -769,7 +769,7 @@
booker,
booking,
bookNewTimePath,
organizer,

Check warning on line 772 in apps/web/test/utils/bookingScenario/expects.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

apps/web/test/utils/bookingScenario/expects.ts#L772

[@typescript-eslint/no-unused-vars] 'organizer' is defined but never used. Allowed unused args must match /^_/u.
}: {
emails: Fixtures["emails"];
organizer: ReturnType<typeof getOrganizer>;
Expand Down Expand Up @@ -975,6 +975,44 @@
});
}

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,
Expand Down
8 changes: 6 additions & 2 deletions packages/features/bookings/lib/handleCancelBooking.ts
Expand Up @@ -200,6 +200,8 @@ async function handler(req: CustomRequest) {
id: bookingToDelete.userId,
},
select: {
id: true,
username:true,
name: true,
email: true,
timeZone: true,
Expand Down Expand Up @@ -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,
Expand All @@ -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! },
Expand Down