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: wrong Meeting Ended payload in zapier #18202

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions packages/features/bookings/lib/handleConfirmation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";
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"] });
Expand Down Expand Up @@ -154,6 +155,8 @@ export async function handleConfirmation(args: {
smsReminderNumber: string | null;
metadata: Prisma.JsonValue | null;
customInputs: Prisma.JsonValue;
title: string;
responses: Prisma.JsonValue;
eventType: {
bookingFields: Prisma.JsonValue | null;
slug: string;
Expand Down Expand Up @@ -230,7 +233,9 @@ export async function handleConfirmation(args: {
},
description: true,
attendees: true,
responses: true,
location: true,
title: true,
uid: true,
startTime: true,
metadata: true,
Expand Down Expand Up @@ -290,6 +295,8 @@ export async function handleConfirmation(args: {
},
uid: true,
startTime: true,
responses: true,
title: true,
metadata: true,
endTime: true,
smsReminderNumber: true,
Expand Down Expand Up @@ -389,8 +396,18 @@ export async function handleConfirmation(args: {

const scheduleTriggerPromises: Promise<unknown>[] = [];

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,
Expand All @@ -402,7 +419,7 @@ export async function handleConfirmation(args: {
});
});
subscribersMeetingEnded.forEach((subscriber) => {
updatedBookings.forEach((booking) => {
updatedBookingsWithCalEventResponses.forEach((booking) => {
scheduleTriggerPromises.push(
scheduleTrigger({
booking,
Expand Down
12 changes: 10 additions & 2 deletions packages/features/bookings/lib/handleNewBooking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ import type { EventPayloadType, EventTypeInfo } from "../../webhooks/lib/sendPay
import { getAllCredentials } from "./getAllCredentialsForUsersOnEvent/getAllCredentials";
import { refreshCredentials } from "./getAllCredentialsForUsersOnEvent/refreshCredentials";
import getBookingDataSchema from "./getBookingDataSchema";
import { getCalEventResponses } from "./getCalEventResponses";
import { addVideoCallDataToEvent } from "./handleNewBooking/addVideoCallDataToEvent";
import { checkBookingAndDurationLimits } from "./handleNewBooking/checkBookingAndDurationLimits";
import { checkIfBookerEmailIsBlocked } from "./handleNewBooking/checkIfBookerEmailIsBlocked";
Expand Down Expand Up @@ -1816,10 +1817,17 @@ async function handler(
}

if (booking && booking.status === BookingStatus.ACCEPTED) {
const bookingWithCalEventResponses = {
...booking,
...getCalEventResponses({
bookingFields: eventType?.bookingFields ?? null,
booking,
}),
};
for (const subscriber of subscribersMeetingEnded) {
scheduleTriggerPromises.push(
scheduleTrigger({
booking,
booking: bookingWithCalEventResponses,
subscriberUrl: subscriber.subscriberUrl,
subscriber,
triggerEvent: WebhookTriggerEvents.MEETING_ENDED,
Expand All @@ -1830,7 +1838,7 @@ async function handler(
for (const subscriber of subscribersMeetingStarted) {
scheduleTriggerPromises.push(
scheduleTrigger({
booking,
booking: bookingWithCalEventResponses,
subscriberUrl: subscriber.subscriberUrl,
subscriber,
triggerEvent: WebhookTriggerEvents.MEETING_STARTED,
Expand Down
25 changes: 24 additions & 1 deletion packages/features/webhooks/lib/scheduleTrigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading