Skip to content

Commit 810caa3

Browse files
Merge pull request #58593 from nextcloud/carl/share-spring-cleaning
2 parents c98244a + 7fa4471 commit 810caa3

30 files changed

Lines changed: 44 additions & 1111 deletions

apps/files_sharing/composer/composer/autoload_classmap.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@
9696
'OCA\\Files_Sharing\\ResponseDefinitions' => $baseDir . '/../lib/ResponseDefinitions.php',
9797
'OCA\\Files_Sharing\\Scanner' => $baseDir . '/../lib/Scanner.php',
9898
'OCA\\Files_Sharing\\Settings\\Personal' => $baseDir . '/../lib/Settings/Personal.php',
99-
'OCA\\Files_Sharing\\ShareBackend\\File' => $baseDir . '/../lib/ShareBackend/File.php',
100-
'OCA\\Files_Sharing\\ShareBackend\\Folder' => $baseDir . '/../lib/ShareBackend/Folder.php',
10199
'OCA\\Files_Sharing\\ShareTargetValidator' => $baseDir . '/../lib/ShareTargetValidator.php',
102100
'OCA\\Files_Sharing\\SharedMount' => $baseDir . '/../lib/SharedMount.php',
103101
'OCA\\Files_Sharing\\SharedStorage' => $baseDir . '/../lib/SharedStorage.php',

apps/files_sharing/composer/composer/autoload_static.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ class ComposerStaticInitFiles_Sharing
111111
'OCA\\Files_Sharing\\ResponseDefinitions' => __DIR__ . '/..' . '/../lib/ResponseDefinitions.php',
112112
'OCA\\Files_Sharing\\Scanner' => __DIR__ . '/..' . '/../lib/Scanner.php',
113113
'OCA\\Files_Sharing\\Settings\\Personal' => __DIR__ . '/..' . '/../lib/Settings/Personal.php',
114-
'OCA\\Files_Sharing\\ShareBackend\\File' => __DIR__ . '/..' . '/../lib/ShareBackend/File.php',
115-
'OCA\\Files_Sharing\\ShareBackend\\Folder' => __DIR__ . '/..' . '/../lib/ShareBackend/Folder.php',
116114
'OCA\\Files_Sharing\\ShareTargetValidator' => __DIR__ . '/..' . '/../lib/ShareTargetValidator.php',
117115
'OCA\\Files_Sharing\\SharedMount' => __DIR__ . '/..' . '/../lib/SharedMount.php',
118116
'OCA\\Files_Sharing\\SharedStorage' => __DIR__ . '/..' . '/../lib/SharedStorage.php',

apps/files_sharing/lib/AppInfo/Application.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
namespace OCA\Files_Sharing\AppInfo;
99

1010
use OC\Group\DisplayNameCache as GroupDisplayNameCache;
11-
use OC\Share\Share;
1211
use OC\User\DisplayNameCache;
1312
use OCA\Files\Event\LoadAdditionalScriptsEvent;
1413
use OCA\Files\Event\LoadSidebar;
@@ -34,8 +33,6 @@
3433
use OCA\Files_Sharing\MountProvider;
3534
use OCA\Files_Sharing\Notification\Listener;
3635
use OCA\Files_Sharing\Notification\Notifier;
37-
use OCA\Files_Sharing\ShareBackend\File;
38-
use OCA\Files_Sharing\ShareBackend\Folder;
3936
use OCP\AppFramework\App;
4037
use OCP\AppFramework\Bootstrap\IBootContext;
4138
use OCP\AppFramework\Bootstrap\IBootstrap;
@@ -132,9 +129,6 @@ public function boot(IBootContext $context): void {
132129
$context->injectFn([$this, 'registerEventsScripts']);
133130

134131
Helper::registerHooks();
135-
136-
Share::registerBackend('file', File::class);
137-
Share::registerBackend('folder', Folder::class, 'file');
138132
}
139133

140134

apps/files_sharing/lib/Controller/ShareesAPIController.php

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ public function search(string $search = '', ?string $itemType = null, int $page
128128
$shareTypes[] = IShare::TYPE_GROUP;
129129
}
130130

131-
if ($this->isRemoteSharingAllowed($itemType)) {
131+
if ($this->isRemoteSharingAllowed()) {
132132
$shareTypes[] = IShare::TYPE_REMOTE;
133133
}
134134

135-
if ($this->isRemoteGroupSharingAllowed($itemType)) {
135+
if ($this->isRemoteGroupSharingAllowed()) {
136136
$shareTypes[] = IShare::TYPE_REMOTE_GROUP;
137137
}
138138

@@ -309,11 +309,11 @@ public function findRecommended(string $itemType, $shareType = null): DataRespon
309309
$shareTypes[] = IShare::TYPE_GROUP;
310310
}
311311

312-
if ($this->isRemoteSharingAllowed($itemType)) {
312+
if ($this->isRemoteSharingAllowed()) {
313313
$shareTypes[] = IShare::TYPE_REMOTE;
314314
}
315315

316-
if ($this->isRemoteGroupSharingAllowed($itemType)) {
316+
if ($this->isRemoteGroupSharingAllowed()) {
317317
$shareTypes[] = IShare::TYPE_REMOTE_GROUP;
318318
}
319319

@@ -353,24 +353,12 @@ public function findRecommended(string $itemType, $shareType = null): DataRespon
353353
* @param string $itemType
354354
* @return bool
355355
*/
356-
protected function isRemoteSharingAllowed(string $itemType): bool {
357-
try {
358-
// FIXME: static foo makes unit testing unnecessarily difficult
359-
$backend = Share::getBackend($itemType);
360-
return $backend->isShareTypeAllowed(IShare::TYPE_REMOTE);
361-
} catch (\Exception $e) {
362-
return false;
363-
}
356+
protected function isRemoteSharingAllowed(): bool {
357+
return $this->federatedShareProvider->isOutgoingServer2serverShareEnabled();
364358
}
365359

366-
protected function isRemoteGroupSharingAllowed(string $itemType): bool {
367-
try {
368-
// FIXME: static foo makes unit testing unnecessarily difficult
369-
$backend = Share::getBackend($itemType);
370-
return $backend->isShareTypeAllowed(IShare::TYPE_REMOTE_GROUP);
371-
} catch (\Exception $e) {
372-
return false;
373-
}
360+
protected function isRemoteGroupSharingAllowed(): bool {
361+
return $this->federatedShareProvider->isOutgoingServer2serverGroupShareEnabled();
374362
}
375363

376364

apps/files_sharing/lib/External/Storage.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@
3030
use OCP\Files\StorageNotAvailableException;
3131
use OCP\Http\Client\IClientService;
3232
use OCP\Http\Client\LocalServerException;
33+
use OCP\IAppConfig;
3334
use OCP\ICacheFactory;
3435
use OCP\IConfig;
36+
use OCP\IUserSession;
3537
use OCP\OCM\Exceptions\OCMArgumentException;
3638
use OCP\OCM\Exceptions\OCMProviderException;
3739
use OCP\OCM\IOCMDiscoveryService;
3840
use OCP\Server;
39-
use OCP\Util;
41+
use OCP\Share\IManager as IShareManager;
4042
use Psr\Log\LoggerInterface;
4143

4244
class Storage extends DAV implements ISharedStorage, IDisableEncryptionStorage, IReliableEtagStorage {
@@ -48,6 +50,8 @@ class Storage extends DAV implements ISharedStorage, IDisableEncryptionStorage,
4850
private bool $updateChecked = false;
4951
private ExternalShareManager $manager;
5052
private IConfig $config;
53+
private IAppConfig $appConfig;
54+
private IShareManager $shareManager;
5155

5256
/**
5357
* @param array{HttpClientService: IClientService, manager: ExternalShareManager, cloudId: ICloudId, mountpoint: string, token: string, password: ?string}|array $options
@@ -60,6 +64,8 @@ public function __construct($options) {
6064
$this->logger = Server::get(LoggerInterface::class);
6165
$discoveryService = Server::get(IOCMDiscoveryService::class);
6266
$this->config = Server::get(IConfig::class);
67+
$this->appConfig = Server::get(IAppConfig::class);
68+
$this->shareManager = Server::get(IShareManager::class);
6369

6470
// use default path to webdav if not found on discovery
6571
try {
@@ -330,7 +336,8 @@ public function getOwner(string $path): string|false {
330336
}
331337

332338
public function isSharable(string $path): bool {
333-
if (Util::isSharingDisabledForUser() || !Share::isResharingAllowed()) {
339+
if ($this->shareManager->sharingDisabledForUser(Server::get(IUserSession::class)->getUser()?->getUID())
340+
|| !$this->appConfig->getValueBool('core', 'shareapi_allow_resharing', true)) {
334341
return false;
335342
}
336343
return (bool)($this->getPermissions($path) & Constants::PERMISSION_SHARE);

apps/files_sharing/lib/Helper.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static function registerHooks() {
2929
* @param View $view
3030
* @return string $path
3131
*/
32-
public static function generateUniqueTarget($path, $view) {
32+
public static function generateUniqueTarget(string $path, View $view): string {
3333
$pathinfo = pathinfo($path);
3434
$ext = isset($pathinfo['extension']) ? '.' . $pathinfo['extension'] : '';
3535
$name = $pathinfo['filename'];
@@ -82,13 +82,4 @@ public static function getShareFolder(?View $view = null, ?string $userId = null
8282

8383
return $shareFolder;
8484
}
85-
86-
/**
87-
* set default share folder
88-
*
89-
* @param string $shareFolder
90-
*/
91-
public static function setShareFolder($shareFolder) {
92-
Server::get(IConfig::class)->setSystemValue('share_folder', $shareFolder);
93-
}
9485
}

apps/files_sharing/lib/ShareBackend/File.php

Lines changed: 0 additions & 228 deletions
This file was deleted.

0 commit comments

Comments
 (0)