* add new trigger with first simple job scheduling * fix DB update * use array to save scheduled jobs in booking * cancel scheduled jobs when zap disabled or zapier disconnected * schedule jobs only for confirmed bookings * schedule jobs for already existing bookings * fix bug to create workflow reminders when confirming recurring events * delete remove all zapier webhooks when api key is deleted * schedule job for all confirmed recurring bookings * fix zapier trigger and workflow reminders when cancelling recurring events * code clean up * code clean up * add migration * add type package for node-schedule * remove nodescheduler * add updated nodescheduler * move code to app-store * add meeting ended to webhook constants * udpate zapier README.md * implement QA suggestions * add default handler and fix imports * Type fix Co-authored-by: CarinaWolli <wollencarina@gmail.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> Co-authored-by: Omar López <zomars@me.com>
49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
import type { NextApiRequest, NextApiResponse } from "next";
|
|
|
|
import findValidApiKey from "@calcom/features/ee/api-keys/lib/findValidApiKey";
|
|
import { defaultHandler, defaultResponder } from "@calcom/lib/server";
|
|
import prisma, { bookingMinimalSelect } from "@calcom/prisma";
|
|
|
|
async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|
const apiKey = req.query.apiKey as string;
|
|
|
|
if (!apiKey) {
|
|
return res.status(401).json({ message: "No API key provided" });
|
|
}
|
|
|
|
const validKey = await findValidApiKey(apiKey, "zapier");
|
|
|
|
if (!validKey) {
|
|
return res.status(401).json({ message: "API key not valid" });
|
|
}
|
|
|
|
try {
|
|
const bookings = await prisma.booking.findMany({
|
|
take: 3,
|
|
where: {
|
|
userId: validKey.userId,
|
|
},
|
|
select: {
|
|
...bookingMinimalSelect,
|
|
location: true,
|
|
attendees: {
|
|
select: {
|
|
name: true,
|
|
email: true,
|
|
timeZone: true,
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
res.status(201).json(bookings);
|
|
} catch (error) {
|
|
console.error(error);
|
|
return res.status(500).json({ message: "Unable to get bookings." });
|
|
}
|
|
}
|
|
|
|
export default defaultHandler({
|
|
GET: Promise.resolve({ default: defaultResponder(handler) }),
|
|
});
|