ExternalSharesController.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OCA\Files_Sharing\Controller;
  8. use OCP\AppFramework\Controller;
  9. use OCP\AppFramework\Http\Attribute\NoAdminRequired;
  10. use OCP\AppFramework\Http\JSONResponse;
  11. use OCP\IRequest;
  12. /**
  13. * Class ExternalSharesController
  14. *
  15. * @package OCA\Files_Sharing\Controller
  16. */
  17. class ExternalSharesController extends Controller {
  18. public function __construct(
  19. string $appName,
  20. IRequest $request,
  21. private \OCA\Files_Sharing\External\Manager $externalManager,
  22. ) {
  23. parent::__construct($appName, $request);
  24. }
  25. /**
  26. * @NoOutgoingFederatedSharingRequired
  27. *
  28. * @return JSONResponse
  29. */
  30. #[NoAdminRequired]
  31. public function index() {
  32. return new JSONResponse($this->externalManager->getOpenShares());
  33. }
  34. /**
  35. * @NoOutgoingFederatedSharingRequired
  36. *
  37. * @param int $id
  38. * @return JSONResponse
  39. */
  40. #[NoAdminRequired]
  41. public function create($id) {
  42. $this->externalManager->acceptShare($id);
  43. return new JSONResponse();
  44. }
  45. /**
  46. * @NoOutgoingFederatedSharingRequired
  47. *
  48. * @param integer $id
  49. * @return JSONResponse
  50. */
  51. #[NoAdminRequired]
  52. public function destroy($id) {
  53. $this->externalManager->declineShare($id);
  54. return new JSONResponse();
  55. }
  56. }