From 817135433af8a8c2345394cf50e4f22d7cfe5745 Mon Sep 17 00:00:00 2001 From: Carlos Santos <4a.santos@gmail.com> Date: Tue, 15 Apr 2025 12:55:43 +0200 Subject: [PATCH] backend: Update bulk delete recordings response to handle mixed results and add appropriate status codes --- .../responses/success-bulk-delete-recordings.yaml | 15 ++------------- backend/openapi/paths/recordings.yaml | 7 +++++++ backend/src/controllers/recording.controller.ts | 6 ++++++ 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/backend/openapi/components/responses/success-bulk-delete-recordings.yaml b/backend/openapi/components/responses/success-bulk-delete-recordings.yaml index 16f4005..5025ae5 100644 --- a/backend/openapi/components/responses/success-bulk-delete-recordings.yaml +++ b/backend/openapi/components/responses/success-bulk-delete-recordings.yaml @@ -1,4 +1,4 @@ -description: Bulk deletion completed. Includes lists of successfully deleted IDs and errors. +description: Mixed results for bulk deletion operation content: application/json: schema: @@ -8,10 +8,7 @@ content: type: array items: type: string - description: List of successfully deleted recording IDs. - example: - - 'room-123--EG_XYZ--XX445' - - 'room-123--EG_ZYX--XX446' + description: List of recordings that were deleted successfully. notDeleted: type: array description: List of recordings that could not be deleted along with the corresponding error messages. @@ -27,14 +24,6 @@ content: description: A message explaining why the deletion failed. example: 'Recording not found' examples: - successful_deletion: - summary: All recordings were successfully deleted - value: - deleted: - - 'room-123--EG_XYZ--XX445' - - 'room-123--EG_ZYX--XX446' - notDeleted: [] - partial_deletion_with_errors: summary: Some recordings were deleted successfully, others failed value: diff --git a/backend/openapi/paths/recordings.yaml b/backend/openapi/paths/recordings.yaml index edd615d..ccafe9f 100644 --- a/backend/openapi/paths/recordings.yaml +++ b/backend/openapi/paths/recordings.yaml @@ -60,6 +60,13 @@ responses: '200': $ref: '../components/responses/success-bulk-delete-recordings.yaml' + description: > + **Mixed results**. Some recordings were deleted successfully while others + could not be deleted (e.g., due to being in progress or not found). + '204': + description: > + All specified recordings were deleted successfully. + No content is returned. '401': $ref: '../components/responses/unauthorized-error.yaml' '403': diff --git a/backend/src/controllers/recording.controller.ts b/backend/src/controllers/recording.controller.ts index a70116f..fd856ed 100644 --- a/backend/src/controllers/recording.controller.ts +++ b/backend/src/controllers/recording.controller.ts @@ -61,6 +61,12 @@ export const bulkDeleteRecordings = async (req: Request, res: Response) => { const recordingIdsArray = (recordingIds as string).split(','); const { deleted, notDeleted } = await recordingService.bulkDeleteRecordings(recordingIdsArray); + // All recordings were successfully deleted + if (deleted.length > 0 && notDeleted.length === 0) { + return res.sendStatus(204); + } + + // Some or all recordings could not be deleted return res.status(200).json({ deleted, notDeleted }); } catch (error) { if (error instanceof OpenViduMeetError) {