Files
calendar/packages/features/webhooks/lib/service/OOOWebhookService.ts
T
Syed Ali ShahbazandGitHub c4c62369e5 chore: Infrastructure scaffolding for Webhook's Producer/Consumer approach before wiring (#25954)
* --INIT

* fixes

* better comments and some clean up

* test and type fix

* clean up

* address feedback

* fix erroneous booking_confirmed to booking_rescheduled
2026-01-22 18:33:34 +05:30

66 lines
1.8 KiB
TypeScript

import { WebhookTriggerEvents } from "@calcom/prisma/enums";
import type { OOOCreatedDTO } from "../dto/types";
import type { ILogger, ITasker } from "../interface/infrastructure";
import type { IOOOWebhookService, IWebhookRepository } from "../interface/services";
import type { IWebhookNotifier } from "../interface/webhook";
import { WebhookService } from "./WebhookService";
export class OOOWebhookService extends WebhookService implements IOOOWebhookService {
constructor(
private readonly notifier: IWebhookNotifier,
repository: IWebhookRepository,
tasker: ITasker,
logger: ILogger
) {
super(repository, tasker, logger);
}
async emitOOOCreated(params: {
oooEntry: {
id: number;
start: string;
end: string;
createdAt: string;
updatedAt: string;
notes: string | null;
reason: {
emoji?: string;
reason?: string;
};
reasonId: number;
user: {
id: number;
name: string | null;
username: string | null;
timeZone: string;
email: string;
};
toUser: {
id: number;
name?: string | null;
username?: string | null;
email?: string;
timeZone?: string;
} | null;
uuid: string;
};
userId?: number | null;
teamId?: number | null;
orgId?: number | null;
platformClientId?: string;
isDryRun?: boolean;
}): Promise<void> {
const dto: OOOCreatedDTO = {
triggerEvent: WebhookTriggerEvents.OOO_CREATED,
createdAt: new Date().toISOString(),
userId: params.userId,
teamId: params.teamId,
orgId: params.orgId,
platformClientId: params.platformClientId,
oooEntry: params.oooEntry,
};
await this.notifier.emitWebhook(dto, params.isDryRun);
}
}