aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/lib/Controller/RemoteController.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_sharing/lib/Controller/RemoteController.php')
-rw-r--r--apps/files_sharing/lib/Controller/RemoteController.php61
1 files changed, 19 insertions, 42 deletions
diff --git a/apps/files_sharing/lib/Controller/RemoteController.php b/apps/files_sharing/lib/Controller/RemoteController.php
index b507bf6a04a..8c15cd8463e 100644
--- a/apps/files_sharing/lib/Controller/RemoteController.php
+++ b/apps/files_sharing/lib/Controller/RemoteController.php
@@ -1,32 +1,17 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Bjoern Schiessle <bjoern@schiessle.org>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Kate Döen <kate.doeen@nextcloud.com>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_Sharing\Controller;
+use OC\Files\View;
use OCA\Files_Sharing\External\Manager;
use OCA\Files_Sharing\ResponseDefinitions;
use OCP\AppFramework\Http;
+use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCS\OCSForbiddenException;
use OCP\AppFramework\OCS\OCSNotFoundException;
@@ -39,8 +24,6 @@ use Psr\Log\LoggerInterface;
*/
class RemoteController extends OCSController {
/**
- * @NoAdminRequired
- *
* Remote constructor.
*
* @param string $appName
@@ -57,29 +40,27 @@ class RemoteController extends OCSController {
}
/**
- * @NoAdminRequired
- *
* Get list of pending remote shares
*
- * @return DataResponse<Http::STATUS_OK, Files_SharingRemoteShare[], array{}>
+ * @return DataResponse<Http::STATUS_OK, list<Files_SharingRemoteShare>, array{}>
*
* 200: Pending remote shares returned
*/
+ #[NoAdminRequired]
public function getOpenShares() {
return new DataResponse($this->externalManager->getOpenShares());
}
/**
- * @NoAdminRequired
- *
* Accept a remote share
*
* @param int $id ID of the share
- * @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, list<empty>, array{}>
* @throws OCSNotFoundException Share not found
*
* 200: Share accepted successfully
*/
+ #[NoAdminRequired]
public function acceptShare($id) {
if ($this->externalManager->acceptShare($id)) {
return new DataResponse();
@@ -92,16 +73,15 @@ class RemoteController extends OCSController {
}
/**
- * @NoAdminRequired
- *
* Decline a remote share
*
* @param int $id ID of the share
- * @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, list<empty>, array{}>
* @throws OCSNotFoundException Share not found
*
* 200: Share declined successfully
*/
+ #[NoAdminRequired]
public function declineShare($id) {
if ($this->externalManager->declineShare($id)) {
return new DataResponse();
@@ -118,7 +98,7 @@ class RemoteController extends OCSController {
* @return array enriched share info with data from the filecache
*/
private static function extendShareInfo($share) {
- $view = new \OC\Files\View('/' . \OC_User::getUser() . '/files/');
+ $view = new View('/' . \OC_User::getUser() . '/files/');
$info = $view->getFileInfo($share['mountpoint']);
if ($info === false) {
@@ -135,24 +115,21 @@ class RemoteController extends OCSController {
}
/**
- * @NoAdminRequired
- *
* Get a list of accepted remote shares
*
- * @return DataResponse<Http::STATUS_OK, Files_SharingRemoteShare[], array{}>
+ * @return DataResponse<Http::STATUS_OK, list<Files_SharingRemoteShare>, array{}>
*
* 200: Accepted remote shares returned
*/
+ #[NoAdminRequired]
public function getShares() {
$shares = $this->externalManager->getAcceptedShares();
- $shares = array_map('self::extendShareInfo', $shares);
+ $shares = array_map(self::extendShareInfo(...), $shares);
return new DataResponse($shares);
}
/**
- * @NoAdminRequired
- *
* Get info of a remote share
*
* @param int $id ID of the share
@@ -161,6 +138,7 @@ class RemoteController extends OCSController {
*
* 200: Share returned
*/
+ #[NoAdminRequired]
public function getShare($id) {
$shareInfo = $this->externalManager->getShare($id);
@@ -173,17 +151,16 @@ class RemoteController extends OCSController {
}
/**
- * @NoAdminRequired
- *
* Unshare a remote share
*
* @param int $id ID of the share
- * @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
+ * @return DataResponse<Http::STATUS_OK, list<empty>, array{}>
* @throws OCSNotFoundException Share not found
* @throws OCSForbiddenException Unsharing is not possible
*
* 200: Share unshared successfully
*/
+ #[NoAdminRequired]
public function unshare($id) {
$shareInfo = $this->externalManager->getShare($id);