diff --git a/.github/workflows/integration-pgsql.yml b/.github/workflows/integration-pgsql.yml index 104109b7215..9574ffbe51c 100644 --- a/.github/workflows/integration-pgsql.yml +++ b/.github/workflows/integration-pgsql.yml @@ -53,7 +53,7 @@ jobs: matrix: test-suite: ['callapi', 'chat-1', 'chat-2', 'command', 'conversation-1', 'conversation-2', 'conversation-3', 'conversation-4', 'conversation-5', 'federation', 'integration', 'sharing-1', 'sharing-2', 'sharing-3', 'sharing-4'] php-versions: ['8.3'] - server-versions: ['master'] + server-versions: ['feat/appframework/route-attribute'] guests-versions: ['master'] call-summary-bot-versions: ['main'] notifications-versions: ['master'] diff --git a/.github/workflows/phpunit-pgsql.yml b/.github/workflows/phpunit-pgsql.yml index ac3a8326abf..8c8bddc75cf 100644 --- a/.github/workflows/phpunit-pgsql.yml +++ b/.github/workflows/phpunit-pgsql.yml @@ -51,7 +51,7 @@ jobs: strategy: matrix: php-versions: ['8.2'] - server-versions: ['master'] + server-versions: ['feat/appframework/route-attribute'] services: postgres: diff --git a/appinfo/routes/routesPageController.php b/appinfo/routes/routesPageController.php index 0fcad372a88..5b82ae574b6 100644 --- a/appinfo/routes/routesPageController.php +++ b/appinfo/routes/routesPageController.php @@ -35,8 +35,6 @@ ['name' => 'Page#notFound', 'url' => '/not-found', 'verb' => 'GET'], /** @see \OCA\Talk\Controller\PageController::duplicateSession() */ ['name' => 'Page#duplicateSession', 'url' => '/duplicate-session', 'verb' => 'GET'], - /** @see \OCA\Talk\Controller\PageController::showCall() */ - ['name' => 'Page#showCall', 'url' => '/call/{token}', 'root' => '', 'verb' => 'GET', 'requirements' => $requirements], /** @see \OCA\Talk\Controller\PageController::authenticatePassword() */ ['name' => 'Page#authenticatePassword', 'url' => '/call/{token}', 'root' => '', 'verb' => 'POST', 'requirements' => $requirements], /** @see \OCA\Talk\Controller\PageController::recording() */ diff --git a/appinfo/routes/routesPollController.php b/appinfo/routes/routesPollController.php index 9e404521a64..507a57993c7 100644 --- a/appinfo/routes/routesPollController.php +++ b/appinfo/routes/routesPollController.php @@ -38,8 +38,6 @@ 'ocs' => [ /** @see \OCA\Talk\Controller\PollController::createPoll() */ ['name' => 'Poll#createPoll', 'url' => '/api/{apiVersion}/poll/{token}', 'verb' => 'POST', 'requirements' => $requirements], - /** @see \OCA\Talk\Controller\PollController::showPoll() */ - ['name' => 'Poll#showPoll', 'url' => '/api/{apiVersion}/poll/{token}/{pollId}', 'verb' => 'GET', 'requirements' => $requirementsWithPollId], /** @see \OCA\Talk\Controller\PollController::votePoll() */ ['name' => 'Poll#votePoll', 'url' => '/api/{apiVersion}/poll/{token}/{pollId}', 'verb' => 'POST', 'requirements' => $requirementsWithPollId], /** @see \OCA\Talk\Controller\PollController::closePoll() */ diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index 37c8f52db94..5e0eab3bc30 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -42,6 +42,7 @@ use OCP\AppFramework\Controller; use OCP\AppFramework\Http; use OCP\AppFramework\Http\Attribute\BruteForceProtection; +use OCP\AppFramework\Http\Attribute\FrontpageRoute; use OCP\AppFramework\Http\Attribute\NoCSRFRequired; use OCP\AppFramework\Http\Attribute\OpenAPI; use OCP\AppFramework\Http\Attribute\PublicPage; @@ -114,6 +115,7 @@ public function __construct( #[PublicPage] #[UseSession] #[BruteForceProtection(action: 'talkRoomToken')] + #[FrontpageRoute(verb: 'GET', url: '/call/{token}', requirements: ['token' => '[a-z0-9]{4,30}'], root: '')] public function showCall(string $token): Response { // This is the entry point from the `/call/{token}` URL which is hardcoded in the server. return $this->index($token); diff --git a/lib/Controller/PollController.php b/lib/Controller/PollController.php index 762529e08e3..40c8d4a6dc4 100644 --- a/lib/Controller/PollController.php +++ b/lib/Controller/PollController.php @@ -42,6 +42,7 @@ use OCA\Talk\Service\PollService; use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Http; +use OCP\AppFramework\Http\Attribute\ApiRoute; use OCP\AppFramework\Http\Attribute\PublicPage; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Utility\ITimeFactory; @@ -143,6 +144,7 @@ public function createPoll(string $question, array $options, int $resultMode, in #[PublicPage] #[RequireModeratorOrNoLobby] #[RequireParticipant] + #[ApiRoute(verb: 'GET', url: '/api/{apiVersion}/poll/{token}/{pollId}', requirements: ['apiVersion' => '(v1)', 'token' => '[a-z0-9]{4,30}', 'pollId' => '\d+'])] public function showPoll(int $pollId): DataResponse { try { $poll = $this->pollService->getPoll($this->room->getId(), $pollId); diff --git a/openapi-full.json b/openapi-full.json index b62ebb4c7e6..a7d4a10228b 100644 --- a/openapi-full.json +++ b/openapi-full.json @@ -7885,9 +7885,9 @@ } }, "/ocs/v2.php/apps/spreed/api/{apiVersion}/poll/{token}/{pollId}": { - "get": { - "operationId": "poll-show-poll", - "summary": "Get a poll", + "post": { + "operationId": "poll-vote-poll", + "summary": "Vote on a poll", "tags": [ "poll" ], @@ -7901,6 +7901,19 @@ } ], "parameters": [ + { + "name": "optionIds[]", + "in": "query", + "description": "IDs of the selected options", + "schema": { + "type": "array", + "default": [], + "items": { + "type": "integer", + "format": "int64" + } + } + }, { "name": "apiVersion", "in": "path", @@ -7946,7 +7959,7 @@ ], "responses": { "200": { - "description": "Poll returned", + "description": "Voted successfully", "content": { "application/json": { "schema": { @@ -7975,6 +7988,34 @@ } } }, + "400": { + "description": "Voting is not possible", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } + }, "404": { "description": "Poll not found", "content": { @@ -8005,9 +8046,9 @@ } } }, - "post": { - "operationId": "poll-vote-poll", - "summary": "Vote on a poll", + "delete": { + "operationId": "poll-close-poll", + "summary": "Close a poll", "tags": [ "poll" ], @@ -8021,19 +8062,6 @@ } ], "parameters": [ - { - "name": "optionIds[]", - "in": "query", - "description": "IDs of the selected options", - "schema": { - "type": "array", - "default": [], - "items": { - "type": "integer", - "format": "int64" - } - } - }, { "name": "apiVersion", "in": "path", @@ -8079,7 +8107,7 @@ ], "responses": { "200": { - "description": "Voted successfully", + "description": "Poll closed successfully", "content": { "application/json": { "schema": { @@ -8109,7 +8137,35 @@ } }, "400": { - "description": "Voting is not possible", + "description": "Poll already closed", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } + }, + "403": { + "description": "Missing permissions to close poll", "content": { "application/json": { "schema": { @@ -8163,12 +8219,40 @@ } } } + }, + "500": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } } } }, - "delete": { - "operationId": "poll-close-poll", - "summary": "Close a poll", + "get": { + "operationId": "poll-show-poll", + "summary": "Get a poll", "tags": [ "poll" ], @@ -8227,7 +8311,7 @@ ], "responses": { "200": { - "description": "Poll closed successfully", + "description": "Poll returned", "content": { "application/json": { "schema": { @@ -8256,62 +8340,6 @@ } } }, - "400": { - "description": "Poll already closed", - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "ocs" - ], - "properties": { - "ocs": { - "type": "object", - "required": [ - "meta", - "data" - ], - "properties": { - "meta": { - "$ref": "#/components/schemas/OCSMeta" - }, - "data": {} - } - } - } - } - } - } - }, - "403": { - "description": "Missing permissions to close poll", - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "ocs" - ], - "properties": { - "ocs": { - "type": "object", - "required": [ - "meta", - "data" - ], - "properties": { - "meta": { - "$ref": "#/components/schemas/OCSMeta" - }, - "data": {} - } - } - } - } - } - } - }, "404": { "description": "Poll not found", "content": { @@ -8339,34 +8367,6 @@ } } } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "ocs" - ], - "properties": { - "ocs": { - "type": "object", - "required": [ - "meta", - "data" - ], - "properties": { - "meta": { - "$ref": "#/components/schemas/OCSMeta" - }, - "data": {} - } - } - } - } - } - } } } } diff --git a/openapi.json b/openapi.json index 13f90ffc08f..8c5f8b2f320 100644 --- a/openapi.json +++ b/openapi.json @@ -7789,9 +7789,9 @@ } }, "/ocs/v2.php/apps/spreed/api/{apiVersion}/poll/{token}/{pollId}": { - "get": { - "operationId": "poll-show-poll", - "summary": "Get a poll", + "post": { + "operationId": "poll-vote-poll", + "summary": "Vote on a poll", "tags": [ "poll" ], @@ -7805,6 +7805,19 @@ } ], "parameters": [ + { + "name": "optionIds[]", + "in": "query", + "description": "IDs of the selected options", + "schema": { + "type": "array", + "default": [], + "items": { + "type": "integer", + "format": "int64" + } + } + }, { "name": "apiVersion", "in": "path", @@ -7850,7 +7863,7 @@ ], "responses": { "200": { - "description": "Poll returned", + "description": "Voted successfully", "content": { "application/json": { "schema": { @@ -7879,6 +7892,34 @@ } } }, + "400": { + "description": "Voting is not possible", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } + }, "404": { "description": "Poll not found", "content": { @@ -7909,9 +7950,9 @@ } } }, - "post": { - "operationId": "poll-vote-poll", - "summary": "Vote on a poll", + "delete": { + "operationId": "poll-close-poll", + "summary": "Close a poll", "tags": [ "poll" ], @@ -7925,19 +7966,6 @@ } ], "parameters": [ - { - "name": "optionIds[]", - "in": "query", - "description": "IDs of the selected options", - "schema": { - "type": "array", - "default": [], - "items": { - "type": "integer", - "format": "int64" - } - } - }, { "name": "apiVersion", "in": "path", @@ -7983,7 +8011,7 @@ ], "responses": { "200": { - "description": "Voted successfully", + "description": "Poll closed successfully", "content": { "application/json": { "schema": { @@ -8013,7 +8041,35 @@ } }, "400": { - "description": "Voting is not possible", + "description": "Poll already closed", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } + }, + "403": { + "description": "Missing permissions to close poll", "content": { "application/json": { "schema": { @@ -8067,12 +8123,40 @@ } } } + }, + "500": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } } } }, - "delete": { - "operationId": "poll-close-poll", - "summary": "Close a poll", + "get": { + "operationId": "poll-show-poll", + "summary": "Get a poll", "tags": [ "poll" ], @@ -8131,7 +8215,7 @@ ], "responses": { "200": { - "description": "Poll closed successfully", + "description": "Poll returned", "content": { "application/json": { "schema": { @@ -8160,62 +8244,6 @@ } } }, - "400": { - "description": "Poll already closed", - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "ocs" - ], - "properties": { - "ocs": { - "type": "object", - "required": [ - "meta", - "data" - ], - "properties": { - "meta": { - "$ref": "#/components/schemas/OCSMeta" - }, - "data": {} - } - } - } - } - } - } - }, - "403": { - "description": "Missing permissions to close poll", - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "ocs" - ], - "properties": { - "ocs": { - "type": "object", - "required": [ - "meta", - "data" - ], - "properties": { - "meta": { - "$ref": "#/components/schemas/OCSMeta" - }, - "data": {} - } - } - } - } - } - } - }, "404": { "description": "Poll not found", "content": { @@ -8243,34 +8271,6 @@ } } } - }, - "500": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "ocs" - ], - "properties": { - "ocs": { - "type": "object", - "required": [ - "meta", - "data" - ], - "properties": { - "meta": { - "$ref": "#/components/schemas/OCSMeta" - }, - "data": {} - } - } - } - } - } - } } } }