Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable27] fix(recording): Stop broken recording backend #12401

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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());
}
Expand Down
17 changes: 17 additions & 0 deletions lib/Controller/RecordingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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) {
Expand Down
Loading