backend: Update bulk delete recordings response to handle mixed results and add appropriate status codes

This commit is contained in:
Carlos Santos 2025-04-15 12:55:43 +02:00
parent 2207b7651f
commit 817135433a
3 changed files with 15 additions and 13 deletions

View File

@ -1,4 +1,4 @@
description: Bulk deletion completed. Includes lists of successfully deleted IDs and errors. description: Mixed results for bulk deletion operation
content: content:
application/json: application/json:
schema: schema:
@ -8,10 +8,7 @@ content:
type: array type: array
items: items:
type: string type: string
description: List of successfully deleted recording IDs. description: List of recordings that were deleted successfully.
example:
- 'room-123--EG_XYZ--XX445'
- 'room-123--EG_ZYX--XX446'
notDeleted: notDeleted:
type: array type: array
description: List of recordings that could not be deleted along with the corresponding error messages. 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. description: A message explaining why the deletion failed.
example: 'Recording not found' example: 'Recording not found'
examples: 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: partial_deletion_with_errors:
summary: Some recordings were deleted successfully, others failed summary: Some recordings were deleted successfully, others failed
value: value:

View File

@ -60,6 +60,13 @@
responses: responses:
'200': '200':
$ref: '../components/responses/success-bulk-delete-recordings.yaml' $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': '401':
$ref: '../components/responses/unauthorized-error.yaml' $ref: '../components/responses/unauthorized-error.yaml'
'403': '403':

View File

@ -61,6 +61,12 @@ export const bulkDeleteRecordings = async (req: Request, res: Response) => {
const recordingIdsArray = (recordingIds as string).split(','); const recordingIdsArray = (recordingIds as string).split(',');
const { deleted, notDeleted } = await recordingService.bulkDeleteRecordings(recordingIdsArray); 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 }); return res.status(200).json({ deleted, notDeleted });
} catch (error) { } catch (error) {
if (error instanceof OpenViduMeetError) { if (error instanceof OpenViduMeetError) {