From 1cfd1ce6ee2a3b48a74cacbe9aa85aaf1bd34856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Sun, 26 Jan 2020 10:42:52 +0100 Subject: [PATCH] Add canCreateBoards to capabilities and update documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- docs/API-Nextcloud.md | 29 +++++++++++++++++++++++++++++ lib/Capabilities.php | 16 +++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/docs/API-Nextcloud.md b/docs/API-Nextcloud.md index a8a59d2af..8f50fe57c 100644 --- a/docs/API-Nextcloud.md +++ b/docs/API-Nextcloud.md @@ -1,5 +1,34 @@ # Nextcloud APIs +## Capabilities + +The [Nextcloud Capabilities API](https://docs.nextcloud.com/server/latest/developer_manual/client_apis/OCS/ocs-api-overview.html#capabilities-api) provides the following information for the Deck app: + +- `version` Current version of the Deck app running +- `canCreateBoards` Ability of the current user to create new boards for themselves + +``` +{ + "ocs": { + "meta": { + "status": "ok", + "statuscode": 200, + "message": "OK" + }, + "data": { + "capabilities": { + "deck": { + "version": "0.8.0", + "canCreateBoards": true + }, + } + } + } +} +``` + + + ## Available sharees When sharing a board to a user, group or circle, the possible sharees can be obtained though the files_sharing API. diff --git a/lib/Capabilities.php b/lib/Capabilities.php index 1a7435236..6fb37eebc 100644 --- a/lib/Capabilities.php +++ b/lib/Capabilities.php @@ -23,10 +23,23 @@ namespace OCA\Deck; +use OCA\Deck\Service\PermissionService; +use OCP\App\IAppManager; use OCP\Capabilities\ICapability; class Capabilities implements ICapability { + /** @var IAppManager */ + private $appManager; + /** @var PermissionService */ + private $permissionService; + + + public function __construct(IAppManager $appManager, PermissionService $permissionService) { + $this->appManager = $appManager; + $this->permissionService = $permissionService; + } + /** * Function an app uses to return the capabilities * @@ -36,7 +49,8 @@ class Capabilities implements ICapability { public function getCapabilities() { return [ 'deck' => [ - 'version' => \OC::$server->getAppManager()->getAppVersion('deck') + 'version' => $this->appManager->getAppVersion('deck'), + 'canCreateBoards' => $this->permissionService->canCreate() ] ]; }