From 5b17efc5a2b18551caa31cb19763a6375781b30a Mon Sep 17 00:00:00 2001 From: juancarmore Date: Wed, 3 Sep 2025 12:33:30 +0200 Subject: [PATCH] backend: enhance auto-deletion policy validation to disallow 'FAIL' options --- .../room-validator.middleware.ts | 27 ++++++++++++++++--- .../src/services/livekit-webhook.service.ts | 2 +- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/backend/src/middlewares/request-validators/room-validator.middleware.ts b/backend/src/middlewares/request-validators/room-validator.middleware.ts index 490804e..900d6c3 100644 --- a/backend/src/middlewares/request-validators/room-validator.middleware.ts +++ b/backend/src/middlewares/request-validators/room-validator.middleware.ts @@ -127,10 +127,29 @@ const RoomRequestOptionsSchema: z.ZodType = z.object({ `autoDeletionDate must be at least ${INTERNAL_CONFIG.MIN_FUTURE_TIME_FOR_ROOM_AUTODELETION_DATE} in the future` ) .optional(), - autoDeletionPolicy: RoomAutoDeletionPolicySchema.optional().default({ - withMeeting: MeetRoomDeletionPolicyWithMeeting.WHEN_MEETING_ENDS, - withRecordings: MeetRoomDeletionPolicyWithRecordings.CLOSE - }), + autoDeletionPolicy: RoomAutoDeletionPolicySchema.optional() + .default({ + withMeeting: MeetRoomDeletionPolicyWithMeeting.WHEN_MEETING_ENDS, + withRecordings: MeetRoomDeletionPolicyWithRecordings.CLOSE + }) + .refine( + (policy) => { + return !policy || policy.withMeeting !== MeetRoomDeletionPolicyWithMeeting.FAIL; + }, + { + message: 'FAIL policy is not allowed for withMeeting auto-deletion policy', + path: ['withMeeting'] + } + ) + .refine( + (policy) => { + return !policy || policy.withRecordings !== MeetRoomDeletionPolicyWithRecordings.FAIL; + }, + { + message: 'FAIL policy is not allowed for withRecordings auto-deletion policy', + path: ['withRecordings'] + } + ), preferences: RoomPreferencesSchema.optional().default({ recordingPreferences: { enabled: true, allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_SPEAKER }, chatPreferences: { enabled: true }, diff --git a/backend/src/services/livekit-webhook.service.ts b/backend/src/services/livekit-webhook.service.ts index 794f150..2639313 100644 --- a/backend/src/services/livekit-webhook.service.ts +++ b/backend/src/services/livekit-webhook.service.ts @@ -243,7 +243,7 @@ export class LivekitWebhookService { `Deleting room '${roomId}' (and its recordings if any) after meeting finished because it was scheduled to be deleted` ); await this.recordingService.deleteAllRoomRecordings(roomId); // This operation must complete before deleting the room - tasks.push(this.roomService.bulkDeleteRooms([roomId], true)); + tasks.push(this.storageService.deleteMeetRooms([roomId])); break; case MeetingEndAction.CLOSE: this.logger.info(