summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVitor Mattos <vitor@php.rio>2022-12-12 14:26:59 -0300
committerVitor Mattos <vitor@php.rio>2022-12-12 14:26:59 -0300
commitb06786de2583d81a4abe5177ff4a44a27fdce155 (patch)
treeb596960fac12e3f28b9ec82f6a3d7540db687b79
parent0f179b79d5817cc93b1f8e3653c5010cc7f5ea46 (diff)
Moved methods of recording api to specific controller
Signed-off-by: Vitor Mattos <vitor@php.rio>
-rw-r--r--appinfo/routes/routesRecordingController.php38
-rw-r--r--docs/index.md1
-rw-r--r--docs/recording.md33
-rw-r--r--lib/Controller/RecordingController.php66
-rw-r--r--mkdocs.yml1
-rw-r--r--tests/integration/features/bootstrap/FeatureContext.php4
-rw-r--r--tests/integration/features/recording/recording.feature (renamed from tests/integration/features/callapi/recording.feature)2
7 files changed, 142 insertions, 3 deletions
diff --git a/appinfo/routes/routesRecordingController.php b/appinfo/routes/routesRecordingController.php
new file mode 100644
index 000000000..88d4c576f
--- /dev/null
+++ b/appinfo/routes/routesRecordingController.php
@@ -0,0 +1,38 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2022 Vitor Mattos <vitor@php.rio>
+ *
+ * @author Vitor Mattos <vitor@php.rio>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+$requirements = [
+ 'apiVersion' => 'v1',
+ 'token' => '[a-z0-9]{4,30}',
+];
+
+return [
+ 'ocs' => [
+ /** @see \OCA\Talk\Controller\RecordingController::startRecording() */
+ ['name' => 'Recording#startRecording', 'url' => '/api/{apiVersion}/recording/{token}', 'verb' => 'POST', 'requirements' => $requirements],
+ /** @see \OCA\Talk\Controller\RecordingController::stopRecording() */
+ ['name' => 'Recording#stopRecording', 'url' => '/api/{apiVersion}/recording/{token}', 'verb' => 'DELETE', 'requirements' => $requirements],
+ ],
+];
diff --git a/docs/index.md b/docs/index.md
index 3e1dec1dc..98858fa0c 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -15,6 +15,7 @@
* [Conversation API](conversation.md)
* [Participant API](participant.md)
* [Call API](call.md)
+* [Call recordingn API](call.md)
* [Chat API](chat.md)
* [Reaction API](reaction.md)
* [Webinar API](webinar.md)
diff --git a/docs/recording.md b/docs/recording.md
new file mode 100644
index 000000000..b3afa04c3
--- /dev/null
+++ b/docs/recording.md
@@ -0,0 +1,33 @@
+# Call recording API
+
+* API v1: 🏁 since Nextcloud 26
+
+## Start call recording
+
+* Required capability: `recording-v1`
+* Method: `POST`
+* Endpoint: `/recording/{token}`
+* Data:
+
+| Field | Type | Description |
+| ------ | ---- | ----------------------------------------------------- |
+| status | int | Type of call recording when 1 is video and 2 is audio |
+
+* 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
+
+## Stop call recording
+
+* Required capability: `recording-v1`
+* Method: `DELETE`
+* Endpoint: `/recording/{token}`
+
+* 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
diff --git a/lib/Controller/RecordingController.php b/lib/Controller/RecordingController.php
new file mode 100644
index 000000000..c361863e6
--- /dev/null
+++ b/lib/Controller/RecordingController.php
@@ -0,0 +1,66 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2022 Vitor Mattos <vitor@php.rio>
+ *
+ * @author Vitor Mattos <vitor@php.rio>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Talk\Controller;
+
+use OCA\Talk\Service\RoomService;
+use OCP\AppFramework\Http;
+use OCP\AppFramework\Http\DataResponse;
+use OCP\IRequest;
+
+class RecordingController extends AEnvironmentAwareController {
+ private RoomService $roomService;
+
+ public function __construct(string $appName,
+ IRequest $request,
+ RoomService $roomService) {
+ parent::__construct($appName, $request);
+ $this->roomService = $roomService;
+ }
+
+ /**
+ * @PublicPage
+ * @RequireCallEnabled
+ * @RequireModeratorParticipant
+ * @RequireCallRecording
+ */
+ public function startRecording(int $status): DataResponse {
+ if (!$this->roomService->startRecording($this->room, $status)) {
+ return new DataResponse([], Http::STATUS_BAD_REQUEST);
+ }
+ return new DataResponse();
+ }
+
+ /**
+ * @PublicPage
+ * @RequireCallEnabled
+ * @RequireModeratorParticipant
+ * @RequireCallRecording
+ */
+ public function stopRecording(): DataResponse {
+ $this->roomService->stopRecording($this->room);
+ return new DataResponse();
+ }
+}
diff --git a/mkdocs.yml b/mkdocs.yml
index 2b7b02e70..734b1913a 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -25,6 +25,7 @@ nav:
- 'Conversations management': 'conversation.md'
- 'Participants management': 'participant.md'
- 'Call management': 'call.md'
+ - 'Call recording management': 'recording.md'
- 'Chat management': 'chat.md'
- 'Reaction management': 'reaction.md'
- 'Poll management': 'poll.md'
diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php
index cb4af0bbd..26c54477f 100644
--- a/tests/integration/features/bootstrap/FeatureContext.php
+++ b/tests/integration/features/bootstrap/FeatureContext.php
@@ -2975,7 +2975,7 @@ class FeatureContext implements Context, SnippetAcceptingContext {
$this->setCurrentUser($user);
$roomToken = self::$identifierToToken[$identifier];
- $this->sendRequest('POST', '/apps/spreed/api/' . $apiVersion . '/call/' . $roomToken . '/recording', $data);
+ $this->sendRequest('POST', '/apps/spreed/api/' . $apiVersion . '/recording/' . $roomToken, $data);
$this->assertStatusCode($this->response, $statusCode);
}
@@ -2985,7 +2985,7 @@ class FeatureContext implements Context, SnippetAcceptingContext {
public function userStopRecordingInRoom(string $user, string $identifier, int $statusCode, string $apiVersion = 'v1'): void {
$this->setCurrentUser($user);
$roomToken = self::$identifierToToken[$identifier];
- $this->sendRequest('DELETE', '/apps/spreed/api/' . $apiVersion . '/call/' . $roomToken . '/recording');
+ $this->sendRequest('DELETE', '/apps/spreed/api/' . $apiVersion . '/recording/' . $roomToken);
$response = $this->response->getBody()->getContents();
$this->assertStatusCode($this->response, $statusCode);
}
diff --git a/tests/integration/features/callapi/recording.feature b/tests/integration/features/recording/recording.feature
index 0f3ceabd4..431f65224 100644
--- a/tests/integration/features/callapi/recording.feature
+++ b/tests/integration/features/recording/recording.feature
@@ -1,4 +1,4 @@
-Feature: callapi/recording
+Feature: recording/recording
Background:
Given user "participant1" exists
Given user "participant2" exists