2014-12-04 13:51:04 -05:00
|
|
|
<?php
|
2025-06-30 09:04:05 -04:00
|
|
|
|
2014-12-04 13:51:04 -05:00
|
|
|
/**
|
2024-06-06 13:48:28 -04:00
|
|
|
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2014-12-04 13:51:04 -05:00
|
|
|
*/
|
2016-10-24 05:46:25 -04:00
|
|
|
namespace OCA\Files_Sharing\Controller;
|
2014-12-04 13:51:04 -05:00
|
|
|
|
2025-10-29 11:50:50 -04:00
|
|
|
use OCA\Files_Sharing\External\Manager;
|
2014-12-04 13:51:04 -05:00
|
|
|
use OCP\AppFramework\Controller;
|
2024-07-25 07:14:46 -04:00
|
|
|
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
|
2014-12-04 13:51:04 -05:00
|
|
|
use OCP\AppFramework\Http\JSONResponse;
|
2019-11-22 14:52:10 -05:00
|
|
|
use OCP\IRequest;
|
2014-12-04 13:51:04 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class ExternalSharesController
|
|
|
|
|
*
|
2016-10-24 05:46:25 -04:00
|
|
|
* @package OCA\Files_Sharing\Controller
|
2014-12-04 13:51:04 -05:00
|
|
|
*/
|
|
|
|
|
class ExternalSharesController extends Controller {
|
2023-10-11 05:52:10 -04:00
|
|
|
public function __construct(
|
|
|
|
|
string $appName,
|
|
|
|
|
IRequest $request,
|
2025-10-29 11:50:50 -04:00
|
|
|
private readonly Manager $externalManager,
|
2023-10-11 05:52:10 -04:00
|
|
|
) {
|
2014-12-04 13:51:04 -05:00
|
|
|
parent::__construct($appName, $request);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2015-10-02 03:57:33 -04:00
|
|
|
* @NoOutgoingFederatedSharingRequired
|
2014-12-04 13:51:04 -05:00
|
|
|
*/
|
2024-07-25 07:14:46 -04:00
|
|
|
#[NoAdminRequired]
|
2025-10-29 11:50:50 -04:00
|
|
|
public function index(): JSONResponse {
|
2015-10-02 03:57:33 -04:00
|
|
|
return new JSONResponse($this->externalManager->getOpenShares());
|
2014-12-04 13:51:04 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2015-10-02 03:57:33 -04:00
|
|
|
* @NoOutgoingFederatedSharingRequired
|
2014-12-04 13:51:04 -05:00
|
|
|
*/
|
2024-07-25 07:14:46 -04:00
|
|
|
#[NoAdminRequired]
|
2025-10-29 11:50:50 -04:00
|
|
|
public function create(string $id): JSONResponse {
|
|
|
|
|
$externalShare = $this->externalManager->getShare($id);
|
|
|
|
|
if ($externalShare !== false) {
|
|
|
|
|
$this->externalManager->acceptShare($externalShare);
|
|
|
|
|
}
|
2014-12-04 13:51:04 -05:00
|
|
|
return new JSONResponse();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2015-10-02 03:57:33 -04:00
|
|
|
* @NoOutgoingFederatedSharingRequired
|
2014-12-04 13:51:04 -05:00
|
|
|
*/
|
2024-07-25 07:14:46 -04:00
|
|
|
#[NoAdminRequired]
|
2025-10-29 11:50:50 -04:00
|
|
|
public function destroy(string $id): JSONResponse {
|
|
|
|
|
$externalShare = $this->externalManager->getShare($id);
|
|
|
|
|
if ($externalShare !== false) {
|
|
|
|
|
$this->externalManager->declineShare($externalShare);
|
|
|
|
|
}
|
2014-12-04 13:51:04 -05:00
|
|
|
return new JSONResponse();
|
|
|
|
|
}
|
|
|
|
|
}
|