Scheduling infrastructure for absolutely everyone.
Add getWebhook function
Syed Ali Shahbazcd482cd91a44
diff --git a/lib/utils/webhookSubscriptions.ts b/lib/utils/webhookSubscriptions.tsnew file mode 100644index 00000000000..bdf9d95576a--- /dev/null+++ b/lib/utils/webhookSubscriptions.ts@@ -0,0 +1,42 @@+import { WebhookTriggerEvents } from "@prisma/client";++import prisma from "@calcom/prisma";++export type GetSubscriberOptions = {+ userId: number;+ eventTypeId: number;+ triggerEvent: WebhookTriggerEvents;+};++const getWebhooks = async (options: GetSubscriberOptions) => {+ const { userId, eventTypeId } = options;+ const allWebhooks = await prisma.webhook.findMany({+ where: {+ OR: [+ {+ userId,+ },+ {+ eventTypeId,+ },+ ],+ AND: {+ eventTriggers: {+ has: options.triggerEvent,+ },+ active: {+ equals: true,+ },+ },+ },+ select: {+ subscriberUrl: true,+ payloadTemplate: true,+ appId: true,+ },+ });++ return allWebhooks;+};++export default getWebhooks;