feat: Platform OAuthClient Webhooks (#16134)

* wip

* fixup! Merge branch 'main' into platform-oauth-client-webhooks

* wip

* fixup! Merge branch 'main' into platform-oauth-client-webhooks

* fixup! fixup! Merge branch 'main' into platform-oauth-client-webhooks

* fixup! fixup! fixup! Merge branch 'main' into platform-oauth-client-webhooks

* fixup! fixup! fixup! fixup! Merge branch 'main' into platform-oauth-client-webhooks

* fixup! fixup! fixup! fixup! fixup! Merge branch 'main' into platform-oauth-client-webhooks

* fixup! fixup! fixup! fixup! fixup! fixup! Merge branch 'main' into platform-oauth-client-webhooks

* fixup! fixup! fixup! fixup! fixup! fixup! fixup! Merge branch 'main' into platform-oauth-client-webhooks

* fixup! Merge branch 'platform-oauth-client-webhooks' of github.com:calcom/cal.com into platform-oauth-client-webhooks

* fixup! fixup! Merge branch 'platform-oauth-client-webhooks' of github.com:calcom/cal.com into platform-oauth-client-webhooks

---------

Co-authored-by: Peer Richelsen <[email protected]>
This commit is contained in:
MorganandPeer Richelsen authored and GitHub committed 2024-08-09 17:02:39 +02:00
1 parent 4def31e98f
commit dda4b17a7c
47 files changed
+1199 -68

No files matched your search

@@ -54,15 +54,18 @@ const WEBHOOK_TRIGGER_EVENTS_GROUPED_BY_APP_V2: Record<string, WebhookTriggerEve
const WebhookForm = (props: {
webhook?: WebhookFormData;
apps?: (keyof typeof WEBHOOK_TRIGGER_EVENTS_GROUPED_BY_APP_V2)[];
overrideTriggerOptions?: (typeof WEBHOOK_TRIGGER_EVENTS_GROUPED_BY_APP_V2)["core"];
onSubmit: (event: WebhookFormSubmitData) => void;
onCancel?: () => void;
noRoutingFormTriggers: boolean;
selectOnlyInstantMeetingOption?: boolean;
}) => {
const { apps = [], selectOnlyInstantMeetingOption = false } = props;
const { apps = [], selectOnlyInstantMeetingOption = false, overrideTriggerOptions } = props;
const { t } = useLocale();
const triggerOptions = [...WEBHOOK_TRIGGER_EVENTS_GROUPED_BY_APP_V2["core"]];
const triggerOptions = overrideTriggerOptions
? [...overrideTriggerOptions]
: [...WEBHOOK_TRIGGER_EVENTS_GROUPED_BY_APP_V2["core"]];
if (apps) {
for (const app of apps) {
if (app === "routing-forms" && props.noRoutingFormTriggers) continue;
@@ -8,6 +8,7 @@ export type GetSubscriberOptions = {
triggerEvent: WebhookTriggerEvents;
teamId?: number | null;
orgId?: number | null;
oAuthClientId?: string | null;
};
const getWebhooks = async (options: GetSubscriberOptions, prisma: PrismaClient = defaultPrisma) => {
@@ -15,6 +16,7 @@ const getWebhooks = async (options: GetSubscriberOptions, prisma: PrismaClient =
const eventTypeId = options.eventTypeId ?? 0;
const teamId = options.teamId ?? 0;
const orgId = options.orgId ?? 0;
const oAuthClientId = options.oAuthClientId ?? "";
// if we have userId and teamId it is a managed event type and should trigger for team and user
const allWebhooks = await prisma.webhook.findMany({
@@ -34,6 +36,7 @@ const getWebhooks = async (options: GetSubscriberOptions, prisma: PrismaClient =
in: [teamId, orgId],
},
},
{ platformOAuthClientId: oAuthClientId },
],
AND: {
eventTriggers: {