aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/lib/Controller
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2024-10-10 12:40:31 +0200
committerCôme Chilliet <come.chilliet@nextcloud.com>2024-10-15 10:40:25 +0200
commit1580c8612b01bfa780d1a7372080a27d182fb7dd (patch)
treeb2776d0cd254ac9d6e54828978ce18b702f550d5 /apps/files_sharing/lib/Controller
parent4ff9b3e0ce53227e2be47c4c2dcb1fdc3e540b5f (diff)
downloadnextcloud-server-1580c8612b01bfa780d1a7372080a27d182fb7dd.tar.gz
nextcloud-server-1580c8612b01bfa780d1a7372080a27d182fb7dd.zip
chore(apps): Apply new rector configuration to autouse classes
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps/files_sharing/lib/Controller')
-rw-r--r--apps/files_sharing/lib/Controller/DeletedShareAPIController.php3
-rw-r--r--apps/files_sharing/lib/Controller/RemoteController.php3
-rw-r--r--apps/files_sharing/lib/Controller/ShareAPIController.php33
-rw-r--r--apps/files_sharing/lib/Controller/ShareController.php26
-rw-r--r--apps/files_sharing/lib/Controller/ShareesAPIController.php5
5 files changed, 40 insertions, 30 deletions
diff --git a/apps/files_sharing/lib/Controller/DeletedShareAPIController.php b/apps/files_sharing/lib/Controller/DeletedShareAPIController.php
index b61f9995c02..ce30cf373ec 100644
--- a/apps/files_sharing/lib/Controller/DeletedShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/DeletedShareAPIController.php
@@ -17,6 +17,7 @@ use OCP\AppFramework\OCS\OCSException;
use OCP\AppFramework\OCS\OCSNotFoundException;
use OCP\AppFramework\OCSController;
use OCP\AppFramework\QueryException;
+use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use OCP\IGroupManager;
@@ -105,7 +106,7 @@ class DeletedShareAPIController extends OCSController {
}
$result['path'] = $userFolder->getRelativePath($node->getPath());
- if ($node instanceof \OCP\Files\Folder) {
+ if ($node instanceof Folder) {
$result['item_type'] = 'folder';
} else {
$result['item_type'] = 'file';
diff --git a/apps/files_sharing/lib/Controller/RemoteController.php b/apps/files_sharing/lib/Controller/RemoteController.php
index fd3bdf15613..cdac35e0d9c 100644
--- a/apps/files_sharing/lib/Controller/RemoteController.php
+++ b/apps/files_sharing/lib/Controller/RemoteController.php
@@ -6,6 +6,7 @@
*/
namespace OCA\Files_Sharing\Controller;
+use OC\Files\View;
use OCA\Files_Sharing\External\Manager;
use OCA\Files_Sharing\ResponseDefinitions;
use OCP\AppFramework\Http;
@@ -96,7 +97,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) {
diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php
index cf835874677..4cff9987242 100644
--- a/apps/files_sharing/lib/Controller/ShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareAPIController.php
@@ -12,11 +12,13 @@ namespace OCA\Files_Sharing\Controller;
use Exception;
use OC\Files\FileInfo;
use OC\Files\Storage\Wrapper\Wrapper;
+use OCA\Circles\Api\v1\Circles;
use OCA\Files\Helper;
use OCA\Files_Sharing\Exceptions\SharingRightsException;
use OCA\Files_Sharing\External\Storage;
use OCA\Files_Sharing\ResponseDefinitions;
use OCA\Files_Sharing\SharedStorage;
+use OCA\GlobalSiteSelector\Service\SlaveService;
use OCP\App\IAppManager;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
@@ -29,6 +31,7 @@ use OCP\AppFramework\OCS\OCSNotFoundException;
use OCP\AppFramework\OCSController;
use OCP\AppFramework\QueryException;
use OCP\Constants;
+use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\InvalidPathException;
use OCP\Files\IRootFolder;
@@ -410,7 +413,7 @@ class ShareAPIController extends OCSController {
}
try {
- $slaveService = Server::get(\OCA\GlobalSiteSelector\Service\SlaveService::class);
+ $slaveService = Server::get(SlaveService::class);
} catch (\Throwable $e) {
$this->logger->error(
$e->getMessage(),
@@ -619,7 +622,7 @@ class ShareAPIController extends OCSController {
$permissions |= Constants::PERMISSION_READ;
}
- if ($node instanceof \OCP\Files\File) {
+ if ($node instanceof File) {
// Single file shares should never have delete or create permissions
$permissions &= ~Constants::PERMISSION_DELETE;
$permissions &= ~Constants::PERMISSION_CREATE;
@@ -695,7 +698,7 @@ class ShareAPIController extends OCSController {
}
// Public upload can only be set for folders
- if ($node instanceof \OCP\Files\File) {
+ if ($node instanceof File) {
throw new OCSNotFoundException($this->l->t('Public upload is only possible for publicly shared folders'));
}
@@ -766,7 +769,7 @@ class ShareAPIController extends OCSController {
throw new OCSNotFoundException($this->l->t('You cannot share to a Team if the app is not enabled'));
}
- $circle = \OCA\Circles\Api\v1\Circles::detailsCircle($shareWith);
+ $circle = Circles::detailsCircle($shareWith);
// Valid team is required to share
if ($circle === null) {
@@ -864,7 +867,7 @@ class ShareAPIController extends OCSController {
* @throws NotFoundException
*/
private function getSharesInDir(Node $folder): array {
- if (!($folder instanceof \OCP\Files\Folder)) {
+ if (!($folder instanceof Folder)) {
throw new OCSBadRequestException($this->l->t('Not a directory'));
}
@@ -1066,7 +1069,7 @@ class ShareAPIController extends OCSController {
try {
$node = $userFolder->get($path);
$this->lock($node);
- } catch (\OCP\Files\NotFoundException $e) {
+ } catch (NotFoundException $e) {
throw new OCSNotFoundException($this->l->t('Wrong path, file/folder does not exist'));
} catch (LockedException $e) {
throw new OCSNotFoundException($this->l->t('Could not lock path'));
@@ -1287,7 +1290,7 @@ class ShareAPIController extends OCSController {
throw new OCSForbiddenException($this->l->t('Public upload disabled by the administrator'));
}
- if (!($share->getNode() instanceof \OCP\Files\Folder)) {
+ if (!($share->getNode() instanceof Folder)) {
throw new OCSBadRequestException($this->l->t('Public upload is only possible for publicly shared folders'));
}
@@ -1458,7 +1461,7 @@ class ShareAPIController extends OCSController {
*
* @suppress PhanUndeclaredClassMethod
*/
- protected function canAccessShare(\OCP\Share\IShare $share, bool $checkGroups = true): bool {
+ protected function canAccessShare(IShare $share, bool $checkGroups = true): bool {
// A file with permissions 0 can't be accessed by us. So Don't show it
if ($share->getPermissions() === 0) {
return false;
@@ -1531,7 +1534,7 @@ class ShareAPIController extends OCSController {
* @param \OCP\Share\IShare $share the share to check
* @return boolean
*/
- protected function canEditShare(\OCP\Share\IShare $share): bool {
+ protected function canEditShare(IShare $share): bool {
// A file with permissions 0 can't be accessed by us. So Don't show it
if ($share->getPermissions() === 0) {
return false;
@@ -1558,7 +1561,7 @@ class ShareAPIController extends OCSController {
* @param \OCP\Share\IShare $share the share to check
* @return boolean
*/
- protected function canDeleteShare(\OCP\Share\IShare $share): bool {
+ protected function canDeleteShare(IShare $share): bool {
// A file with permissions 0 can't be accessed by us. So Don't show it
if ($share->getPermissions() === 0) {
return false;
@@ -1595,7 +1598,7 @@ class ShareAPIController extends OCSController {
*
* @suppress PhanUndeclaredClassMethod
*/
- protected function canDeleteShareFromSelf(\OCP\Share\IShare $share): bool {
+ protected function canDeleteShareFromSelf(IShare $share): bool {
if ($share->getShareType() !== IShare::TYPE_GROUP &&
$share->getShareType() !== IShare::TYPE_ROOM &&
$share->getShareType() !== IShare::TYPE_DECK &&
@@ -1746,7 +1749,7 @@ class ShareAPIController extends OCSController {
* @param \OCP\Files\Node $node
* @throws LockedException
*/
- private function lock(\OCP\Files\Node $node) {
+ private function lock(Node $node) {
$node->lock(ILockingProvider::LOCK_SHARED);
$this->lockedNode = $node;
}
@@ -1923,7 +1926,7 @@ class ShareAPIController extends OCSController {
return true;
}
- if ((\OCP\Constants::PERMISSION_SHARE & $share->getPermissions()) === 0) {
+ if ((Constants::PERMISSION_SHARE & $share->getPermissions()) === 0) {
return false;
}
@@ -1946,7 +1949,7 @@ class ShareAPIController extends OCSController {
$sharedWith = substr($share->getSharedWith(), $shareWithStart, $shareWithLength);
}
try {
- $member = \OCA\Circles\Api\v1\Circles::getMember($sharedWith, $userId, 1);
+ $member = Circles::getMember($sharedWith, $userId, 1);
if ($member->getLevel() >= 4) {
return true;
}
@@ -2065,7 +2068,7 @@ class ShareAPIController extends OCSController {
} else {
throw new \RuntimeException('Should not happen, instanceOfStorage but not a wrapper');
}
- /** @var \OCA\Files_Sharing\SharedStorage $storage */
+ /** @var SharedStorage $storage */
$inheritedAttributes = $storage->getShare()->getAttributes();
if ($inheritedAttributes !== null && $inheritedAttributes->getAttribute('permissions', 'download') === false) {
$share->setHideDownload(true);
diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php
index e2b607f8eb2..5b2a2af4992 100644
--- a/apps/files_sharing/lib/Controller/ShareController.php
+++ b/apps/files_sharing/lib/Controller/ShareController.php
@@ -17,13 +17,17 @@ use OCP\AppFramework\AuthPublicShareController;
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
use OCP\AppFramework\Http\Attribute\OpenAPI;
use OCP\AppFramework\Http\Attribute\PublicPage;
+use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\NotFoundResponse;
use OCP\AppFramework\Http\RedirectResponse;
use OCP\AppFramework\Http\TemplateResponse;
+use OCP\Constants;
use OCP\Defaults;
use OCP\EventDispatcher\IEventDispatcher;
+use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
+use OCP\Files\Node;
use OCP\Files\NotFoundException;
use OCP\IConfig;
use OCP\IL10N;
@@ -46,7 +50,7 @@ use OCP\Share\IShare;
*/
#[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)]
class ShareController extends AuthPublicShareController {
- protected ?Share\IShare $share = null;
+ protected ?IShare $share = null;
public const SHARE_ACCESS = 'access';
public const SHARE_AUTH = 'auth';
@@ -217,7 +221,7 @@ class ShareController extends AuthPublicShareController {
$itemType = $itemSource = $uidOwner = '';
$token = $share;
$exception = null;
- if ($share instanceof \OCP\Share\IShare) {
+ if ($share instanceof IShare) {
try {
$token = $share->getToken();
$uidOwner = $share->getSharedBy();
@@ -261,7 +265,7 @@ class ShareController extends AuthPublicShareController {
* @param Share\IShare $share
* @return bool
*/
- private function validateShare(\OCP\Share\IShare $share) {
+ private function validateShare(IShare $share) {
// If the owner is disabled no access to the link is granted
$owner = $this->userManager->get($share->getShareOwner());
if ($owner === null || !$owner->isEnabled()) {
@@ -314,7 +318,7 @@ class ShareController extends AuthPublicShareController {
// We can't get the path of a file share
try {
- if ($shareNode instanceof \OCP\Files\File && $path !== '') {
+ if ($shareNode instanceof File && $path !== '') {
$this->emitAccessShareHook($share, 404, 'Share not found');
$this->emitShareAccessEvent($share, self::SHARE_ACCESS, 404, 'Share not found');
throw new NotFoundException($this->l10n->t('This share does not exist or is no longer available'));
@@ -349,8 +353,8 @@ class ShareController extends AuthPublicShareController {
$share = $this->shareManager->getShareByToken($token);
- if (!($share->getPermissions() & \OCP\Constants::PERMISSION_READ)) {
- return new \OCP\AppFramework\Http\DataResponse('Share has no read permission');
+ if (!($share->getPermissions() & Constants::PERMISSION_READ)) {
+ return new DataResponse('Share has no read permission');
}
if (!$this->validateShare($share)) {
@@ -358,7 +362,7 @@ class ShareController extends AuthPublicShareController {
}
// Single file share
- if ($share->getNode() instanceof \OCP\Files\File) {
+ if ($share->getNode() instanceof File) {
// Single file download
$this->singleFileDownloaded($share, $share->getNode());
}
@@ -378,7 +382,7 @@ class ShareController extends AuthPublicShareController {
}
}
- if ($node instanceof \OCP\Files\Folder) {
+ if ($node instanceof Folder) {
if ($files === null || $files === '') {
// The folder is downloaded
$this->singleFileDownloaded($share, $share->getNode());
@@ -415,7 +419,7 @@ class ShareController extends AuthPublicShareController {
* @param Share\IShare $share
* @throws NotFoundException when trying to download a folder of a "hide download" share
*/
- protected function singleFileDownloaded(Share\IShare $share, \OCP\Files\Node $node) {
+ protected function singleFileDownloaded(IShare $share, Node $node) {
if ($share->getHideDownload() && $node instanceof Folder) {
throw new NotFoundException('Downloading a folder');
}
@@ -435,14 +439,14 @@ class ShareController extends AuthPublicShareController {
$parameters = [$userPath];
if ($share->getShareType() === IShare::TYPE_EMAIL) {
- if ($node instanceof \OCP\Files\File) {
+ if ($node instanceof File) {
$subject = Downloads::SUBJECT_SHARED_FILE_BY_EMAIL_DOWNLOADED;
} else {
$subject = Downloads::SUBJECT_SHARED_FOLDER_BY_EMAIL_DOWNLOADED;
}
$parameters[] = $share->getSharedWith();
} else {
- if ($node instanceof \OCP\Files\File) {
+ if ($node instanceof File) {
$subject = Downloads::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED;
$parameters[] = $remoteAddressHash;
} else {
diff --git a/apps/files_sharing/lib/Controller/ShareesAPIController.php b/apps/files_sharing/lib/Controller/ShareesAPIController.php
index f177cb9d1ee..606a3d11de6 100644
--- a/apps/files_sharing/lib/Controller/ShareesAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareesAPIController.php
@@ -10,6 +10,7 @@ namespace OCA\Files_Sharing\Controller;
use Generator;
use OC\Collaboration\Collaborators\SearchResult;
+use OC\Share\Share;
use OCA\Files_Sharing\ResponseDefinitions;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
@@ -362,7 +363,7 @@ class ShareesAPIController extends OCSController {
protected function isRemoteSharingAllowed(string $itemType): bool {
try {
// FIXME: static foo makes unit testing unnecessarily difficult
- $backend = \OC\Share\Share::getBackend($itemType);
+ $backend = Share::getBackend($itemType);
return $backend->isShareTypeAllowed(IShare::TYPE_REMOTE);
} catch (\Exception $e) {
return false;
@@ -372,7 +373,7 @@ class ShareesAPIController extends OCSController {
protected function isRemoteGroupSharingAllowed(string $itemType): bool {
try {
// FIXME: static foo makes unit testing unnecessarily difficult
- $backend = \OC\Share\Share::getBackend($itemType);
+ $backend = Share::getBackend($itemType);
return $backend->isShareTypeAllowed(IShare::TYPE_REMOTE_GROUP);
} catch (\Exception $e) {
return false;