diff --git a/backend/src/controllers/livekit-webhook.controller.ts b/backend/src/controllers/livekit-webhook.controller.ts index 785a8d2..96c5c9b 100644 --- a/backend/src/controllers/livekit-webhook.controller.ts +++ b/backend/src/controllers/livekit-webhook.controller.ts @@ -2,7 +2,6 @@ import { Request, Response } from 'express'; import { LoggerService } from '../services/logger.service.js'; import { LivekitWebhookService } from '../services/livekit-webhook.service.js'; import { WebhookEvent } from 'livekit-server-sdk'; -import { OpenViduWebhookService } from '../services/openvidu-webhook.service.js'; import { container } from '../config/dependency-injector.config.js'; export const lkWebhookHandler = async (req: Request, res: Response) => { @@ -10,7 +9,6 @@ export const lkWebhookHandler = async (req: Request, res: Response) => { try { const lkWebhookService = container.get(LivekitWebhookService); - const ovWebhookService = container.get(OpenViduWebhookService); const webhookEvent: WebhookEvent = await lkWebhookService.getEventFromWebhook( req.body, @@ -39,7 +37,7 @@ export const lkWebhookHandler = async (req: Request, res: Response) => { await lkWebhookService.handleParticipantJoined(room!, participant!); break; case 'room_finished': - await ovWebhookService.sendRoomFinishedWebhook(room!); + await lkWebhookService.handleRoomFinished(room!); break; default: break; diff --git a/backend/src/services/livekit-webhook.service.ts b/backend/src/services/livekit-webhook.service.ts index 6b1f1fd..038e48a 100644 --- a/backend/src/services/livekit-webhook.service.ts +++ b/backend/src/services/livekit-webhook.service.ts @@ -160,6 +160,24 @@ export class LivekitWebhookService { } } + /** + * Handles the event when a room is finished. + * + * This method sends a webhook notification indicating that the room has finished. + * If an error occurs while sending the webhook, it logs the error. + * + * @param {Room} room - The room object that has finished. + * @returns {Promise} A promise that resolves when the webhook has been sent. + */ + async handleRoomFinished(room: Room) { + try { + await this.openViduWebhookService.sendRoomFinishedWebhook(room); + } catch (error) { + this.logger.error(`Error handling room finished event: ${error}`); + } + } + + private async sendStatusSignal(roomName: string, roomId: string, participantSid: string) { // Get recording list const recordingInfo = await this.recordingService.getAllRecordingsByRoom(roomName, roomId);