mirror of
https://github.com/hanzoai/calendar.git
synced 2026-10-30 14:46:43 +00:00
* add webhook version schema * version the code * update version from numeric to date val * migration * update schema and build factory * update string * move version picker * tooltip instead of infobadge * -- * fix type * -- * fix type * fix type * -- * fix messed up merge * improvements to payloadfactory * extract version off of DB and instead keep it in IWebhookRepository * fix webhookform * fix type safety and routing ambiguity * scalable with easier factory extensions and base definition * fix types * -- * -- * clean up prisma/client type imports * fix * type fix * type fix * cleanup * add tests and registry changes * unintended file inclusion * type-fix * select in repo * -- * explicit return type * -- * fix type * fixes * feedback 1 * feedback 2 * use enum instead of string * fixes
51 lines
1.6 KiB
TypeScript
51 lines
1.6 KiB
TypeScript
import { WebhookTriggerEvents } from "@calcom/prisma/enums";
|
|
|
|
import type {
|
|
MeetingStartedDTO,
|
|
MeetingEndedDTO,
|
|
AfterHostsNoShowDTO,
|
|
AfterGuestsNoShowDTO,
|
|
} from "../../../dto/types";
|
|
import type { WebhookPayload } from "../../types";
|
|
import { BaseMeetingPayloadBuilder } from "../../base/BaseMeetingPayloadBuilder";
|
|
|
|
/**
|
|
* Meeting payload builder for webhook version v2021-10-20.
|
|
*
|
|
* Handles:
|
|
* - MEETING_STARTED / MEETING_ENDED: Full booking data in payload
|
|
* - AFTER_HOSTS_CAL_VIDEO_NO_SHOW / AFTER_GUESTS_CAL_VIDEO_NO_SHOW: bookingId and webhook info
|
|
*/
|
|
export class MeetingPayloadBuilder extends BaseMeetingPayloadBuilder {
|
|
/**
|
|
* Build the meeting webhook payload for v2021-10-20.
|
|
*/
|
|
build(
|
|
dto: MeetingStartedDTO | MeetingEndedDTO | AfterHostsNoShowDTO | AfterGuestsNoShowDTO
|
|
): WebhookPayload {
|
|
// Handle no-show events (different payload structure)
|
|
if (
|
|
dto.triggerEvent === WebhookTriggerEvents.AFTER_HOSTS_CAL_VIDEO_NO_SHOW ||
|
|
dto.triggerEvent === WebhookTriggerEvents.AFTER_GUESTS_CAL_VIDEO_NO_SHOW
|
|
) {
|
|
const noShowDto = dto as AfterHostsNoShowDTO | AfterGuestsNoShowDTO;
|
|
return {
|
|
triggerEvent: dto.triggerEvent,
|
|
createdAt: dto.createdAt,
|
|
payload: {
|
|
bookingId: noShowDto.bookingId,
|
|
webhook: noShowDto.webhook,
|
|
},
|
|
};
|
|
}
|
|
|
|
// Handle meeting started/ended events
|
|
const meetingDto = dto as MeetingStartedDTO | MeetingEndedDTO;
|
|
return {
|
|
triggerEvent: dto.triggerEvent,
|
|
createdAt: dto.createdAt,
|
|
payload: { ...meetingDto.booking },
|
|
};
|
|
}
|
|
}
|