From 9306c2ded5b8eec05e239788ab75f6f23bdd25b1 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 16 May 2024 11:37:02 +0200 Subject: [PATCH] fix(recording): Stop broken recording backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Joas Schilling Signed-off-by: Daniel Calviño Sánchez --- lib/Controller/PageController.php | 8 ++++++++ lib/Controller/RecordingController.php | 17 +++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index c14374a5a60..dab317ccb73 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -320,6 +320,7 @@ protected function pageHandler(string $token = '', string $callUser = '', string #[NoCSRFRequired] #[PublicPage] #[BruteForceProtection(action: 'talkRoomToken')] + #[BruteForceProtection(action: 'talkRecordingStatus')] public function recording(string $token): Response { try { $room = $this->manager->getRoomByToken($token); @@ -330,6 +331,13 @@ public function recording(string $token): Response { return $response; } + if ($room->getCallRecording() !== Room::RECORDING_VIDEO_STARTING && $room->getCallRecording() !== Room::RECORDING_AUDIO_STARTING) { + $response = new NotFoundResponse(); + $this->logger->debug('Recording "' . ($this->userId ?? 'ANONYMOUS') . '" throttled for accessing "' . $token . '"', ['app' => 'spreed-bfp']); + $response->throttle(['token' => $token, 'action' => 'talkRecordingStatus']); + return $response; + } + if (class_exists(LoadViewer::class)) { $this->eventDispatcher->dispatchTyped(new LoadViewer()); } diff --git a/lib/Controller/RecordingController.php b/lib/Controller/RecordingController.php index 8b57b9ca5a4..a0db9096753 100644 --- a/lib/Controller/RecordingController.php +++ b/lib/Controller/RecordingController.php @@ -147,6 +147,7 @@ protected function getInputStream(): string { */ #[PublicPage] #[BruteForceProtection(action: 'talkRecordingSecret')] + #[BruteForceProtection(action: 'talkRecordingStatus')] public function backend(): DataResponse { $json = $this->getInputStream(); if (!$this->validateBackendRequest($json)) { @@ -201,6 +202,22 @@ private function backendStarted(array $started): DataResponse { ], Http::STATUS_NOT_FOUND); } + if ($room->getCallRecording() !== Room::RECORDING_VIDEO_STARTING && $room->getCallRecording() !== Room::RECORDING_AUDIO_STARTING) { + $this->logger->error('Recording backend tried to start recording in room {token}, but it was not requested by a moderator.', [ + 'token' => $token, + 'app' => 'spreed-recording', + ]); + $response = new DataResponse([ + 'type' => 'error', + 'error' => [ + 'code' => 'no_such_room', + 'message' => 'Room not found.', + ], + ], Http::STATUS_NOT_FOUND); + $response->throttle(['action' => 'talkRecordingStatus']); + return $response; + } + try { $participant = $this->participantService->getParticipantByActor($room, $actor['type'], $actor['id']); } catch (ParticipantNotFoundException $e) {