refactor: v2 OAuth webhooks & workflows (#17959)

* refactor: handleMarkNoShow OAuth webhook handling

* refactor: confirm / decline booking OAuth webhook handling

* refactor: pass oauth client to calendar event

* refactor: pass oauth params

* fix import

* fix tests

* chore: bump libraries

* chore: bump libraries

* chore: republish platform libraries

* chore: republish platform libraries

* fix: use replexica key in v2 and unit test CI

* lock file

* fixup! Merge branch 'main' into lauris/cal-4807-platform-refactor-oauth-webhooks

* Revert "fix: use replexica key in v2 and unit test CI"

This reverts commit 0bd6c364535f9e11a4d1497a6bd8909885562080.

---------

Co-authored-by: Morgan <[email protected]>
Co-authored-by: Morgan Vernay <[email protected]>
This commit is contained in:
authored and GitHub committed 2024-12-04 11:25:20 +01:00
1 parent b92db55380
commit e2938ac39a
13 files changed
+5834 -107

No files matched your search

@@ -8,6 +8,7 @@ import { getCalEventResponses } from "@calcom/features/bookings/lib/getCalEventR
import { handleConfirmation } from "@calcom/features/bookings/lib/handleConfirmation";
import { handleWebhookTrigger } from "@calcom/features/bookings/lib/handleWebhookTrigger";
import { workflowSelect } from "@calcom/features/ee/workflows/lib/getAllWorkflows";
import type { GetSubscriberOptions } from "@calcom/features/webhooks/lib/getWebhooks";
import type { EventPayloadType, EventTypeInfo } from "@calcom/features/webhooks/lib/sendPayload";
import { isPrismaObjOrUndefined, parseRecurringEvent } from "@calcom/lib";
import { getBookerBaseUrl } from "@calcom/lib/getBookerUrl/server";
@@ -41,7 +42,14 @@ type ConfirmOptions = {
export const confirmHandler = async ({ ctx, input }: ConfirmOptions) => {
const { user } = ctx;
const { bookingId, recurringEventId, reason: rejectionReason, confirmed, emailsEnabled } = input;
const {
bookingId,
recurringEventId,
reason: rejectionReason,
confirmed,
emailsEnabled,
platformClientParams,
} = input;
const tOrganizer = await getTranslation(user.locale ?? "en", "common");
@@ -214,6 +222,7 @@ export const confirmHandler = async ({ ctx, input }: ConfirmOptions) => {
members: [],
}
: undefined,
...(platformClientParams ? platformClientParams : {}),
};
const recurringEvent = parseRecurringEvent(booking.eventType?.recurringEvent);
@@ -270,6 +279,7 @@ export const confirmHandler = async ({ ctx, input }: ConfirmOptions) => {
bookingId,
booking,
emailsEnabled,
platformClientParams,
});
} else {
evt.rejectionReason = rejectionReason;
@@ -383,12 +393,13 @@ export const confirmHandler = async ({ ctx, input }: ConfirmOptions) => {
const orgId = await getOrgIdFromMemberOrTeamId({ memberId: booking.userId, teamId });
// send BOOKING_REJECTED webhooks
const subscriberOptions = {
const subscriberOptions: GetSubscriberOptions = {
userId: booking.userId,
eventTypeId: booking.eventTypeId,
triggerEvent: WebhookTriggerEvents.BOOKING_REJECTED,
teamId,
orgId,
oAuthClientId: platformClientParams?.platformClientId,
};
const eventTrigger: WebhookTriggerEvents = WebhookTriggerEvents.BOOKING_REJECTED;
const eventTypeInfo: EventTypeInfo = {