Capabilities.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OCA\Provisioning_API;
  7. use OCA\FederatedFileSharing\FederatedShareProvider;
  8. use OCP\App\IAppManager;
  9. use OCP\Capabilities\ICapability;
  10. class Capabilities implements ICapability {
  11. public function __construct(
  12. private IAppManager $appManager,
  13. ) {
  14. }
  15. /**
  16. * Function an app uses to return the capabilities
  17. *
  18. * @return array{
  19. * provisioning_api: array{
  20. * version: string,
  21. * AccountPropertyScopesVersion: int,
  22. * AccountPropertyScopesFederatedEnabled: bool,
  23. * AccountPropertyScopesPublishedEnabled: bool,
  24. * },
  25. * }
  26. */
  27. public function getCapabilities() {
  28. $federatedScopeEnabled = $this->appManager->isEnabledForUser('federation');
  29. $publishedScopeEnabled = false;
  30. $federatedFileSharingEnabled = $this->appManager->isEnabledForUser('federatedfilesharing');
  31. if ($federatedFileSharingEnabled) {
  32. /** @var FederatedShareProvider $shareProvider */
  33. $shareProvider = \OC::$server->query(FederatedShareProvider::class);
  34. $publishedScopeEnabled = $shareProvider->isLookupServerUploadEnabled();
  35. }
  36. return [
  37. 'provisioning_api' => [
  38. 'version' => $this->appManager->getAppVersion('provisioning_api'),
  39. 'AccountPropertyScopesVersion' => 2,
  40. 'AccountPropertyScopesFederatedEnabled' => $federatedScopeEnabled,
  41. 'AccountPropertyScopesPublishedEnabled' => $publishedScopeEnabled,
  42. ]
  43. ];
  44. }
  45. }