Files
calendar/packages/features/webhooks/lib/service/RecordingWebhookService.ts
T
Syed Ali ShahbazandGitHub 110615b509 chore: add webhook architecture skeleton (#23247)
* add migration guide and dto

* add factory

* add notifier

* add repo

* add services

* coderabbit review --1

* coderabbit review --2

* coderabbit review --3

* further improvement

* --

* fix

* bookingWebhookFactory consideration and type fixes

* cleanup

* fix types

* DI part1

* DI --part 2

* remove migrationGuide as we're WIP

* using evyweb for DI -- 1

* DI --final

* separate func instead of private class

* adds a todo migration file

* adjust structure

* address feedback

* remove todo_migrate

* --1

* fix type

* address feedback

* add TODO comment

* address requested changes --1

* address feedback --2

* restructure as per feedback

* rename camelcase
2025-09-12 20:02:50 +00:00

74 lines
2.2 KiB
TypeScript

import { WebhookTriggerEvents } from "@calcom/prisma/enums";
import type { CalendarEvent } from "@calcom/types/Calendar";
import type { RecordingReadyDTO, TranscriptionGeneratedDTO } from "../dto/types";
import type { IRecordingWebhookService } from "../interface/services";
import type { IWebhookNotifier } from "../interface/webhook";
export class RecordingWebhookService implements IRecordingWebhookService {
constructor(private readonly webhookNotifier: IWebhookNotifier) {}
async emitRecordingReady(params: {
evt: CalendarEvent;
downloadLink: string;
booking?: {
id: number;
eventTypeId?: number | null;
userId?: number | null;
};
teamId?: number | null;
orgId?: number | null;
platformClientId?: string;
isDryRun?: boolean;
}): Promise<void> {
const dto: RecordingReadyDTO = {
triggerEvent: WebhookTriggerEvents.RECORDING_READY,
createdAt: new Date().toISOString(),
bookingId: params.booking?.id,
eventTypeId: params.booking?.eventTypeId,
userId: params.booking?.userId,
teamId: params.teamId,
orgId: params.orgId,
platformClientId: params.platformClientId,
evt: params.evt,
downloadLink: params.downloadLink,
};
await this.webhookNotifier.emitWebhook(dto, params.isDryRun);
}
async emitTranscriptionGenerated(params: {
evt: CalendarEvent;
downloadLinks?: {
transcription?: Array<{
format: string;
link: string;
}>;
recording?: string;
};
booking?: {
id: number;
eventTypeId?: number | null;
userId?: number | null;
};
teamId?: number | null;
orgId?: number | null;
platformClientId?: string;
isDryRun?: boolean;
}): Promise<void> {
const dto: TranscriptionGeneratedDTO = {
triggerEvent: WebhookTriggerEvents.RECORDING_TRANSCRIPTION_GENERATED,
createdAt: new Date().toISOString(),
bookingId: params.booking?.id,
eventTypeId: params.booking?.eventTypeId,
userId: params.booking?.userId,
teamId: params.teamId,
orgId: params.orgId,
platformClientId: params.platformClientId,
evt: params.evt,
downloadLinks: params.downloadLinks,
};
await this.webhookNotifier.emitWebhook(dto, params.isDryRun);
}
}