fix: wrong Meeting Ended payload in zapier (#18202)

* fix: wrong Meeting Ended payload in zapier

* fix
This commit is contained in:
Kartik Saini
2025-01-10 15:55:35 +01:00
committed by GitHub
parent cec1c9ee46
commit b652ae7714
3 changed files with 49 additions and 5 deletions
@@ -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<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,
@@ -406,7 +423,7 @@ export async function handleConfirmation(args: {
});
});
subscribersMeetingEnded.forEach((subscriber) => {
updatedBookings.forEach((booking) => {
updatedBookingsWithCalEventResponses.forEach((booking) => {
scheduleTriggerPromises.push(
scheduleTrigger({
booking,
@@ -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,
@@ -70,9 +70,32 @@ export async function addSubscription({
},
status: BookingStatus.ACCEPTED,
},
include: {
eventType: {
select: {
bookingFields: true,
},
},
attendees: {
select: {
name: true,
email: true,
},
},
},
});
for (const booking of bookings) {
const bookingsWithCalEventResponses = bookings.map((booking) => {
return {
...booking,
...getCalEventResponses({
bookingFields: booking.eventType?.bookingFields ?? null,
booking,
}),
};
});
for (const booking of bookingsWithCalEventResponses) {
scheduleTrigger({
booking,
subscriberUrl: createSubscription.subscriberUrl,