backend: enhance auto-deletion policy validation to disallow 'FAIL' options

This commit is contained in:
juancarmore 2025-09-03 12:33:30 +02:00
parent 0b3c0e9e42
commit 5b17efc5a2
2 changed files with 24 additions and 5 deletions

View File

@ -127,10 +127,29 @@ const RoomRequestOptionsSchema: z.ZodType<MeetRoomOptions> = z.object({
`autoDeletionDate must be at least ${INTERNAL_CONFIG.MIN_FUTURE_TIME_FOR_ROOM_AUTODELETION_DATE} in the future` `autoDeletionDate must be at least ${INTERNAL_CONFIG.MIN_FUTURE_TIME_FOR_ROOM_AUTODELETION_DATE} in the future`
) )
.optional(), .optional(),
autoDeletionPolicy: RoomAutoDeletionPolicySchema.optional().default({ autoDeletionPolicy: RoomAutoDeletionPolicySchema.optional()
.default({
withMeeting: MeetRoomDeletionPolicyWithMeeting.WHEN_MEETING_ENDS, withMeeting: MeetRoomDeletionPolicyWithMeeting.WHEN_MEETING_ENDS,
withRecordings: MeetRoomDeletionPolicyWithRecordings.CLOSE 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({ preferences: RoomPreferencesSchema.optional().default({
recordingPreferences: { enabled: true, allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_SPEAKER }, recordingPreferences: { enabled: true, allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_SPEAKER },
chatPreferences: { enabled: true }, chatPreferences: { enabled: true },

View File

@ -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` `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 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; break;
case MeetingEndAction.CLOSE: case MeetingEndAction.CLOSE:
this.logger.info( this.logger.info(