From 930d4d54fdc4c1c4bca489a5b6110542367a5b0e Mon Sep 17 00:00:00 2001 From: dartcafe Date: Thu, 4 Apr 2024 23:12:08 +0200 Subject: [PATCH 1/2] adding an acl endpoint to the api controller Signed-off-by: dartcafe --- appinfo/routes.php | 1 + lib/Controller/PollApiController.php | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/appinfo/routes.php b/appinfo/routes.php index a5d574c3a..c0a3675b7 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -140,6 +140,7 @@ ['name' => 'poll_api#transfer_polls', 'url' => '/api/v1.0/polls/transfer/{sourceUser}/{destinationUser}', 'verb' => 'PUT'], ['name' => 'poll_api#transfer_poll', 'url' => '/api/v1.0/poll/{pollId}/transfer/{destinationUser}', 'verb' => 'PUT'], ['name' => 'poll_api#add', 'url' => '/api/v1.0/poll', 'verb' => 'POST'], + ['name' => 'poll_api#get_acl', 'url' => '/api/v1.0/poll/{pollId}/acl', 'verb' => 'GET'], ['name' => 'poll_api#get', 'url' => '/api/v1.0/poll/{pollId}', 'verb' => 'GET'], ['name' => 'poll_api#update', 'url' => '/api/v1.0/poll/{pollId}', 'verb' => 'PUT'], ['name' => 'poll_api#delete', 'url' => '/api/v1.0/poll/{pollId}', 'verb' => 'DELETE'], diff --git a/lib/Controller/PollApiController.php b/lib/Controller/PollApiController.php index 90ea825c5..d249895c3 100644 --- a/lib/Controller/PollApiController.php +++ b/lib/Controller/PollApiController.php @@ -83,6 +83,24 @@ public function get(int $pollId): JSONResponse { } } + /** + * get acl for poll + * @param $pollId Poll id + */ + #[CORS] + #[NoAdminRequired] + #[NoCSRFRequired] + public function getAcl(int $pollId): JSONResponse { + try { + $this->acl->setPollId($pollId); + return new JSONResponse(['acl' => $this->acl], Http::STATUS_OK); + } catch (DoesNotExistException $e) { + return new JSONResponse(['error' => 'Not found'], Http::STATUS_NOT_FOUND); + } catch (Exception $e) { + return new JSONResponse(['message' => $e->getMessage()], $e->getStatus()); + } + } + /** * Add poll * @param string $title Poll title From 6b74bb5cc3608a8865af0cca419d9a0363426ceb Mon Sep 17 00:00:00 2001 From: dartcafe Date: Thu, 4 Apr 2024 23:14:48 +0200 Subject: [PATCH 2/2] changelog Signed-off-by: dartcafe --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a3709d663..d0ecd2e35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file. ## [7.0.3] - tbd ### Fix - Archive, restore and delete polls in poll list was missing, braught the options back to the action menu +### New + - Added an endpoint to the Api to be able to fetch the acl of a poll ## [7.0.2] - 2024-03-29 ### Fix - Combo view was not usable