summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/recording.md12
-rw-r--r--lib/Controller/RecordingController.php12
-rw-r--r--lib/Service/RoomService.php18
3 files changed, 27 insertions, 15 deletions
diff --git a/docs/recording.md b/docs/recording.md
index b3afa04c3..efbf437a1 100644
--- a/docs/recording.md
+++ b/docs/recording.md
@@ -16,9 +16,10 @@
* Response:
- Status code:
+ `200 OK`
- + `400 Bad Request` When the status to start is invalid
- + `400 Bad Request` The haven't the capability `recording-v1`
- + `412 Precondition Failed` When the lobby is active and the user is not a moderator
+ + `400 Bad Request` Message: `status`. When the status to start is invalid.
+ + `400 Bad Request` Message: `config`. Need to enable the config `recording`.
+ + `400 Bad Request` Message: `room`. Already have a recording in progress.
+ + `412 Precondition Failed` When the lobby is active and the user is not a moderator.
## Stop call recording
@@ -29,5 +30,6 @@
* Response:
- Status code:
+ `200 OK`
- + `400 Bad Request` The haven't the capability `recording-v1`
- + `412 Precondition Failed` When the lobby is active and the user is not a moderator
+ + `400 Bad Request` Message: `config`. Need to enable the config `recording`.
+ + `400 Bad Request` Message: `room`. Recording has already been stopped.
+ + `412 Precondition Failed` When the lobby is active and the user is not a moderator.
diff --git a/lib/Controller/RecordingController.php b/lib/Controller/RecordingController.php
index cacf6e9c5..9931258a2 100644
--- a/lib/Controller/RecordingController.php
+++ b/lib/Controller/RecordingController.php
@@ -46,8 +46,10 @@ class RecordingController extends AEnvironmentAwareController {
* @RequireModeratorParticipant
*/
public function startRecording(int $status): DataResponse {
- if (!$this->roomService->startRecording($this->room, $status)) {
- return new DataResponse([], Http::STATUS_BAD_REQUEST);
+ try {
+ $this->roomService->startRecording($this->room, $status)
+ } catch (InvalidArgumentException $e) {
+ return new DataResponse(['error' => $e->getMessage()], Http::STATUS_BAD_REQUEST);
}
return new DataResponse();
}
@@ -58,7 +60,11 @@ class RecordingController extends AEnvironmentAwareController {
* @RequireModeratorParticipant
*/
public function stopRecording(): DataResponse {
- $this->roomService->stopRecording($this->room);
+ try {
+ $this->roomService->stopRecording($this->room);
+ } catch (InvalidArgumentException $e) {
+ return new DataResponse(['error' => $e->getMessage()], Http::STATUS_BAD_REQUEST);
+ }
return new DataResponse();
}
}
diff --git a/lib/Service/RoomService.php b/lib/Service/RoomService.php
index ad7355631..212636f41 100644
--- a/lib/Service/RoomService.php
+++ b/lib/Service/RoomService.php
@@ -367,19 +367,19 @@ class RoomService {
}
public function startRecording(Room $room, $status): bool {
- if (!$this->config->isRecordingEnabled()) {
- return false;
- }
$availableRecordingTypes = [Room::RECORDING_VIDEO, Room::RECORDING_AUDIO];
if (!in_array($status, $availableRecordingTypes)) {
- return false;
+ throw new InvalidArgumentException('status');
+ }
+ if ($room->getCallRecording() !== 0) {
+ throw new InvalidArgumentException('room');
}
return $this->setCallRecording($room, $status);
}
public function stopRecording(Room $room): bool {
- if (!$this->config->isRecordingEnabled()) {
- return false;
+ if ($room->getCallRecording() === 0) {
+ throw new InvalidArgumentException('room');
}
return $this->setCallRecording($room);
}
@@ -389,9 +389,13 @@ class RoomService {
* @param integer $status 0 none|1 video|2 audio
*/
public function setCallRecording(Room $room, int $status = Room::RECORDING_STOP): bool {
+ if (!$this->config->isRecordingEnabled()) {
+ throw new InvalidArgumentException('config');
+ }
+
$availableRecordingStatus = [Room::RECORDING_STOP, Room::RECORDING_VIDEO, Room::RECORDING_AUDIO];
if (!in_array($status, $availableRecordingStatus)) {
- return false;
+ throw new InvalidArgumentException('status');
}
$oldStatus = $room->getCallRecording();