Skip to content

Commit

Permalink
Merge pull request #3416 from nextcloud/enh/add-acl-to-api
Browse files Browse the repository at this point in the history
adding an acl endpoint to the api controller
  • Loading branch information
dartcafe committed Apr 5, 2024
2 parents 1562fce + 6b74bb5 commit a56945d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
18 changes: 18 additions & 0 deletions lib/Controller/PollApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a56945d

Please sign in to comment.