From e7f45dcbfd7cb341647eb63ce092f62c9ccd1dab Mon Sep 17 00:00:00 2001 From: Carlos Santos <4a.santos@gmail.com> Date: Wed, 9 Apr 2025 17:12:50 +0200 Subject: [PATCH] backend: Change stop recording endpoint from PUT to POST and update response status to 202 --- backend/openapi/paths/internal/recordings.yaml | 6 +++--- backend/src/controllers/recording.controller.ts | 2 +- backend/src/routes/recording.routes.ts | 4 ++-- .../src/lib/services/http/http.service.ts | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/backend/openapi/paths/internal/recordings.yaml b/backend/openapi/paths/internal/recordings.yaml index cc87895..aee2b19 100644 --- a/backend/openapi/paths/internal/recordings.yaml +++ b/backend/openapi/paths/internal/recordings.yaml @@ -26,8 +26,8 @@ '500': $ref: '../../components/responses/internal-server-error.yaml' -/recordings/{recordingId}: - put: +/recordings/{recordingId}/stop: + post: operationId: stopRecording summary: Stop a recording description: > @@ -40,7 +40,7 @@ parameters: - $ref: '../../components/parameters/recording-id.yaml' responses: - '200': + '202': $ref: '../../components/responses/success-stop-recording.yaml' '401': $ref: '../../components/responses/unauthorized-error.yaml' diff --git a/backend/src/controllers/recording.controller.ts b/backend/src/controllers/recording.controller.ts index a960257..800b3cf 100644 --- a/backend/src/controllers/recording.controller.ts +++ b/backend/src/controllers/recording.controller.ts @@ -95,7 +95,7 @@ export const stopRecording = async (req: Request, res: Response) => { const recordingInfo = await recordingService.stopRecording(recordingId); res.setHeader('Location', `${req.protocol}://${req.get('host')}${req.originalUrl}`); - return res.status(200).json(recordingInfo); + return res.status(202).json(recordingInfo); } catch (error) { if (error instanceof OpenViduMeetError) { logger.error(`Error stopping recording: ${error.message}`); diff --git a/backend/src/routes/recording.routes.ts b/backend/src/routes/recording.routes.ts index dbfa35b..ff32850 100644 --- a/backend/src/routes/recording.routes.ts +++ b/backend/src/routes/recording.routes.ts @@ -66,8 +66,8 @@ internalRecordingRouter.post( recordingCtrl.startRecording ); -internalRecordingRouter.put( - '/:recordingId', +internalRecordingRouter.post( + '/:recordingId/stop', withValidRecordingId, withRecordingEnabled, withAuth(participantTokenValidator), diff --git a/frontend/projects/shared-meet-components/src/lib/services/http/http.service.ts b/frontend/projects/shared-meet-components/src/lib/services/http/http.service.ts index f6004b6..521b7d1 100644 --- a/frontend/projects/shared-meet-components/src/lib/services/http/http.service.ts +++ b/frontend/projects/shared-meet-components/src/lib/services/http/http.service.ts @@ -9,7 +9,7 @@ import { TokenOptions, User } from '@lib/typings/ce'; -import { RecordingInfo, Room } from 'openvidu-components-angular'; +import { RecordingInfo } from 'openvidu-components-angular'; import { lastValueFrom } from 'rxjs'; @Injectable({ @@ -124,7 +124,7 @@ export class HttpService { } stopRecording(recordingId: string): Promise { - return this.putRequest(`${this.INTERNAL_API_PATH_PREFIX}/${this.API_V1_VERSION}/recordings/${recordingId}`); + return this.postRequest(`${this.INTERNAL_API_PATH_PREFIX}/${this.API_V1_VERSION}/recordings/${recordingId}/stop`); } deleteRecording(recordingId: string): Promise {