1
0

Capabilities.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\ShareByMail;
  8. use OCA\ShareByMail\Settings\SettingsManager;
  9. use OCP\App\IAppManager;
  10. use OCP\Capabilities\ICapability;
  11. use OCP\Share\IManager;
  12. class Capabilities implements ICapability {
  13. public function __construct(
  14. private IManager $manager,
  15. private SettingsManager $settingsManager,
  16. private IAppManager $appManager,
  17. ) {
  18. }
  19. /**
  20. * @return array{
  21. * files_sharing?: array{
  22. * sharebymail: array{
  23. * enabled: bool,
  24. * send_password_by_mail: bool,
  25. * upload_files_drop: array{
  26. * enabled: bool,
  27. * },
  28. * password: array{
  29. * enabled: bool,
  30. * enforced: bool,
  31. * },
  32. * expire_date: array{
  33. * enabled: bool,
  34. * enforced: bool,
  35. * },
  36. * }
  37. * }
  38. * }
  39. */
  40. public function getCapabilities(): array {
  41. if (!$this->appManager->isEnabledForUser('files_sharing')) {
  42. return [];
  43. }
  44. return [
  45. 'files_sharing' =>
  46. [
  47. 'sharebymail' =>
  48. [
  49. 'enabled' => $this->manager->shareApiAllowLinks(),
  50. 'send_password_by_mail' => $this->settingsManager->sendPasswordByMail(),
  51. 'upload_files_drop' => [
  52. 'enabled' => true,
  53. ],
  54. 'password' => [
  55. 'enabled' => true,
  56. 'enforced' => $this->manager->shareApiLinkEnforcePassword(),
  57. ],
  58. 'expire_date' => [
  59. 'enabled' => true,
  60. 'enforced' => $this->manager->shareApiLinkDefaultExpireDateEnforced(),
  61. ],
  62. ]
  63. ]
  64. ];
  65. }
  66. }