-
Notifications
You must be signed in to change notification settings - Fork 13.3k
feat: add zapier no-show support #28927
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| export { default as add } from "./add"; | ||
| export { default as listBookings } from "./subscriptions/listBookings"; | ||
| export { default as listOOOEntries } from "./subscriptions/listOOOEntries"; | ||
| export { default as listNoShowBookings } from "./subscriptions/listNoShowBookings"; | ||
| export { default as deleteSubscription } from "./subscriptions/deleteSubscription"; | ||
| export { default as addSubscription } from "./subscriptions/addSubscription"; | ||
| export { default as me } from "./subscriptions/me"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| import type { NextApiRequest, NextApiResponse } from "next"; | ||
|
|
||
| import prisma from "@calcom/prisma"; | ||
| import { WebhookTriggerEvents } from "@calcom/prisma/enums"; | ||
| import { defaultHandler } from "@calcom/lib/server/defaultHandler"; | ||
| import { defaultResponder } from "@calcom/lib/server/defaultResponder"; | ||
|
|
||
| import { validateAccountOrApiKey } from "../../lib/validateAccountOrApiKey"; | ||
|
|
||
| async function handler(req: NextApiRequest, res: NextApiResponse) { | ||
| const { account: authorizedAccount, appApiKey: validKey } = await validateAccountOrApiKey(req, [ | ||
| "READ_BOOKING", | ||
| ]); | ||
|
Comment on lines
+11
to
+13
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Require profile read permission before returning profile fields. This endpoint authorizes only 🔐 Proposed fix const { account: authorizedAccount, appApiKey: validKey } = await validateAccountOrApiKey(req, [
"READ_BOOKING",
+ "READ_PROFILE",
]);Also applies to: 51-79 🤖 Prompt for AI Agents |
||
|
|
||
| const userId = validKey ? validKey.userId : authorizedAccount && !authorizedAccount.isTeam ? authorizedAccount.id : null; | ||
| const teamId = validKey ? validKey.teamId : authorizedAccount && authorizedAccount.isTeam ? authorizedAccount.id : null; | ||
|
|
||
| const where = teamId | ||
| ? { | ||
| eventType: { | ||
| OR: [{ teamId }, { parent: { teamId } }], | ||
| }, | ||
| OR: [{ noShowHost: true }, { attendees: { some: { noShow: true } } }], | ||
| } | ||
| : { | ||
| eventType: { userId }, | ||
| OR: [{ noShowHost: true }, { attendees: { some: { noShow: true } } }], | ||
| }; | ||
|
|
||
| const noShowBookings = await prisma.booking.findMany({ | ||
| take: 3, | ||
| where, | ||
| orderBy: { | ||
| updatedAt: "desc", | ||
| }, | ||
| select: { | ||
| uid: true, | ||
| title: true, | ||
| description: true, | ||
| customInputs: true, | ||
| responses: true, | ||
| startTime: true, | ||
| endTime: true, | ||
| createdAt: true, | ||
| updatedAt: true, | ||
| location: true, | ||
| cancellationReason: true, | ||
| status: true, | ||
| metadata: true, | ||
| noShowHost: true, | ||
| user: { | ||
| select: { | ||
| username: true, | ||
| name: true, | ||
| email: true, | ||
| timeZone: true, | ||
| locale: true, | ||
| }, | ||
| }, | ||
| eventType: { | ||
| select: { | ||
| title: true, | ||
| description: true, | ||
| requiresConfirmation: true, | ||
| price: true, | ||
| currency: true, | ||
| length: true, | ||
| bookingFields: true, | ||
| team: true, | ||
| }, | ||
| }, | ||
| attendees: { | ||
| select: { | ||
| name: true, | ||
| email: true, | ||
| timeZone: true, | ||
| noShow: true, | ||
| }, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| if (noShowBookings.length === 0) { | ||
| return res.status(200).json([]); | ||
| } | ||
|
|
||
| return res.status(200).json( | ||
| noShowBookings.map((booking) => ({ | ||
| createdAt: booking.updatedAt ?? booking.createdAt, | ||
| triggerEvent: WebhookTriggerEvents.BOOKING_NO_SHOW_UPDATED, | ||
| payload: { | ||
| booking, | ||
| }, | ||
| })) | ||
| ); | ||
| } | ||
|
|
||
| export default defaultHandler({ | ||
| GET: Promise.resolve({ default: defaultResponder(handler) }), | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,7 @@ | |
| "categories": ["automation"], | ||
| "publisher": "Cal.diy", | ||
| "email": "[email protected]", | ||
| "description": "Workflow automation for everyone. Use the Cal.diy Zapier app to automate your workflows when a booking is created, rescheduled, cancelled or when a meeting ends.", | ||
| "description": "Workflow automation for everyone. Use the Cal.diy Zapier app to automate your workflows when a booking is created, rescheduled, cancelled, marked as no-show, or when a meeting ends.", | ||
| "isTemplate": false, | ||
| "__createdUsingCli": true, | ||
| "__template": "link-as-an-app", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filter no-show samples to accepted bookings.
The query currently returns any booking with
noShowHostor attendeenoShow, including cancelled/rejected/pending bookings if those flags remain set. Addstatus: BookingStatus.ACCEPTEDso this list mirrors actual no-show trigger eligibility.🛠️ Proposed fix
Based on learnings, all side effects including no-show triggers are gated on
booking.status === ACCEPTED.Also applies to: 18-28
🤖 Prompt for AI Agents