aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/lib
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2024-02-23 21:51:44 +0100
committerGitHub <noreply@github.com>2024-02-23 21:51:44 +0100
commit0eba9570eb211958461b7deed73aa4b533970e9c (patch)
tree59082de90f5711c3e5de664e821d70a0d5029111 /apps/files_sharing/lib
parentd6eb127f7670d6f5cb5a8d95db8e0ed954df957a (diff)
parent7cf3172f1ced2d1d8d376140e0268a860d228b0b (diff)
downloadnextcloud-server-0eba9570eb211958461b7deed73aa4b533970e9c.tar.gz
nextcloud-server-0eba9570eb211958461b7deed73aa4b533970e9c.zip
Merge branch 'master' into share-external-watcher
Signed-off-by: John Molakvoæ <skjnldsv@users.noreply.github.com>
Diffstat (limited to 'apps/files_sharing/lib')
-rw-r--r--apps/files_sharing/lib/Activity/Providers/Base.php12
-rw-r--r--apps/files_sharing/lib/Activity/Providers/Groups.php14
-rw-r--r--apps/files_sharing/lib/Activity/Providers/RemoteShares.php12
-rw-r--r--apps/files_sharing/lib/AppInfo/Application.php5
-rw-r--r--apps/files_sharing/lib/BackgroundJob/FederatedSharesDiscoverJob.php28
-rw-r--r--apps/files_sharing/lib/Cache.php17
-rw-r--r--apps/files_sharing/lib/Collaboration/ShareRecipientSorter.php1
-rw-r--r--apps/files_sharing/lib/Command/DeleteOrphanShares.php3
-rw-r--r--apps/files_sharing/lib/Command/ExiprationNotification.php8
-rw-r--r--apps/files_sharing/lib/Controller/AcceptController.php4
-rw-r--r--apps/files_sharing/lib/Controller/DeletedShareAPIController.php24
-rw-r--r--apps/files_sharing/lib/Controller/ExternalSharesController.php35
-rw-r--r--apps/files_sharing/lib/Controller/PublicPreviewController.php10
-rw-r--r--apps/files_sharing/lib/Controller/RemoteController.php12
-rw-r--r--apps/files_sharing/lib/Controller/SettingsController.php4
-rw-r--r--apps/files_sharing/lib/Controller/ShareAPIController.php70
-rw-r--r--apps/files_sharing/lib/Controller/ShareController.php23
-rw-r--r--apps/files_sharing/lib/Controller/ShareInfoController.php16
-rw-r--r--apps/files_sharing/lib/Controller/ShareesAPIController.php20
-rw-r--r--apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php3
-rw-r--r--apps/files_sharing/lib/DeleteOrphanedSharesJob.php19
-rw-r--r--apps/files_sharing/lib/External/Manager.php6
-rw-r--r--apps/files_sharing/lib/External/Mount.php3
-rw-r--r--apps/files_sharing/lib/External/MountProvider.php2
-rw-r--r--apps/files_sharing/lib/External/Storage.php97
-rw-r--r--apps/files_sharing/lib/ISharedMountPoint.php28
-rw-r--r--apps/files_sharing/lib/Listener/LoadAdditionalListener.php5
-rw-r--r--apps/files_sharing/lib/Listener/LoadSidebarListener.php12
-rw-r--r--apps/files_sharing/lib/Listener/ShareInteractionListener.php1
-rw-r--r--apps/files_sharing/lib/Listener/UserAddedToGroupListener.php1
-rw-r--r--apps/files_sharing/lib/Listener/UserShareAcceptanceListener.php1
-rw-r--r--apps/files_sharing/lib/Middleware/OCSShareAPIMiddleware.php2
-rw-r--r--apps/files_sharing/lib/Middleware/SharingCheckMiddleware.php12
-rw-r--r--apps/files_sharing/lib/Migration/OwncloudGuestShareType.php2
-rw-r--r--apps/files_sharing/lib/Migration/Version11300Date20201120141438.php2
-rw-r--r--apps/files_sharing/lib/Migration/Version21000Date20201223143245.php2
-rw-r--r--apps/files_sharing/lib/Migration/Version24000Date20220208195521.php2
-rw-r--r--apps/files_sharing/lib/MountProvider.php2
-rw-r--r--apps/files_sharing/lib/Notification/Notifier.php10
-rw-r--r--apps/files_sharing/lib/OrphanHelper.php7
-rw-r--r--apps/files_sharing/lib/ResponseDefinitions.php117
-rw-r--r--apps/files_sharing/lib/ShareBackend/File.php3
-rw-r--r--apps/files_sharing/lib/SharedMount.php15
-rw-r--r--apps/files_sharing/lib/SharedStorage.php18
-rw-r--r--apps/files_sharing/lib/Updater.php2
45 files changed, 386 insertions, 306 deletions
diff --git a/apps/files_sharing/lib/Activity/Providers/Base.php b/apps/files_sharing/lib/Activity/Providers/Base.php
index e9e1d870f9a..01d730242c9 100644
--- a/apps/files_sharing/lib/Activity/Providers/Base.php
+++ b/apps/files_sharing/lib/Activity/Providers/Base.php
@@ -63,12 +63,12 @@ abstract class Base implements IProvider {
protected $displayNames = [];
public function __construct(IFactory $languageFactory,
- IURLGenerator $url,
- IManager $activityManager,
- IUserManager $userManager,
- ICloudIdManager $cloudIdManager,
- IContactsManager $contactsManager,
- IEventMerger $eventMerger) {
+ IURLGenerator $url,
+ IManager $activityManager,
+ IUserManager $userManager,
+ ICloudIdManager $cloudIdManager,
+ IContactsManager $contactsManager,
+ IEventMerger $eventMerger) {
$this->languageFactory = $languageFactory;
$this->url = $url;
$this->activityManager = $activityManager;
diff --git a/apps/files_sharing/lib/Activity/Providers/Groups.php b/apps/files_sharing/lib/Activity/Providers/Groups.php
index b9cc2e6b579..a6e6fae3e9b 100644
--- a/apps/files_sharing/lib/Activity/Providers/Groups.php
+++ b/apps/files_sharing/lib/Activity/Providers/Groups.php
@@ -51,13 +51,13 @@ class Groups extends Base {
protected $groupDisplayNames = [];
public function __construct(IFactory $languageFactory,
- IURLGenerator $url,
- IManager $activityManager,
- IUserManager $userManager,
- ICloudIdManager $cloudIdManager,
- IContactsManager $contactsManager,
- IEventMerger $eventMerger,
- IGroupManager $groupManager) {
+ IURLGenerator $url,
+ IManager $activityManager,
+ IUserManager $userManager,
+ ICloudIdManager $cloudIdManager,
+ IContactsManager $contactsManager,
+ IEventMerger $eventMerger,
+ IGroupManager $groupManager) {
parent::__construct($languageFactory, $url, $activityManager, $userManager, $cloudIdManager, $contactsManager, $eventMerger);
$this->groupManager = $groupManager;
}
diff --git a/apps/files_sharing/lib/Activity/Providers/RemoteShares.php b/apps/files_sharing/lib/Activity/Providers/RemoteShares.php
index e24645f8a26..b46db3105e9 100644
--- a/apps/files_sharing/lib/Activity/Providers/RemoteShares.php
+++ b/apps/files_sharing/lib/Activity/Providers/RemoteShares.php
@@ -40,12 +40,12 @@ class RemoteShares extends Base {
public const SUBJECT_REMOTE_SHARE_UNSHARED = 'remote_share_unshared';
public function __construct(IFactory $languageFactory,
- IURLGenerator $url,
- IManager $activityManager,
- IUserManager $userManager,
- ICloudIdManager $cloudIdManager,
- IContactsManager $contactsManager,
- IEventMerger $eventMerger) {
+ IURLGenerator $url,
+ IManager $activityManager,
+ IUserManager $userManager,
+ ICloudIdManager $cloudIdManager,
+ IContactsManager $contactsManager,
+ IEventMerger $eventMerger) {
parent::__construct($languageFactory, $url, $activityManager, $userManager, $cloudIdManager, $contactsManager, $eventMerger);
}
diff --git a/apps/files_sharing/lib/AppInfo/Application.php b/apps/files_sharing/lib/AppInfo/Application.php
index 603527310ae..fc305e58dbe 100644
--- a/apps/files_sharing/lib/AppInfo/Application.php
+++ b/apps/files_sharing/lib/AppInfo/Application.php
@@ -32,8 +32,9 @@ namespace OCA\Files_Sharing\AppInfo;
use OC\Group\DisplayNameCache as GroupDisplayNameCache;
use OC\Share\Share;
use OC\User\DisplayNameCache;
+use OCA\Files\Event\LoadAdditionalScriptsEvent;
+use OCA\Files\Event\LoadSidebar;
use OCA\Files_Sharing\Capabilities;
-use OCA\Files_Sharing\Event\BeforeTemplateRenderedEvent;
use OCA\Files_Sharing\External\Manager;
use OCA\Files_Sharing\External\MountProvider as ExternalMountProvider;
use OCA\Files_Sharing\Helper;
@@ -48,8 +49,6 @@ use OCA\Files_Sharing\Middleware\SharingCheckMiddleware;
use OCA\Files_Sharing\MountProvider;
use OCA\Files_Sharing\Notification\Listener;
use OCA\Files_Sharing\Notification\Notifier;
-use OCA\Files\Event\LoadAdditionalScriptsEvent;
-use OCA\Files\Event\LoadSidebar;
use OCA\Files_Sharing\ShareBackend\File;
use OCA\Files_Sharing\ShareBackend\Folder;
use OCA\Files_Sharing\ViewOnly;
diff --git a/apps/files_sharing/lib/BackgroundJob/FederatedSharesDiscoverJob.php b/apps/files_sharing/lib/BackgroundJob/FederatedSharesDiscoverJob.php
index 687dcd25f8b..75606960e4b 100644
--- a/apps/files_sharing/lib/BackgroundJob/FederatedSharesDiscoverJob.php
+++ b/apps/files_sharing/lib/BackgroundJob/FederatedSharesDiscoverJob.php
@@ -6,6 +6,7 @@ declare(strict_types=1);
* @copyright 2018, Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
+ * @author Maxence Lange <maxence@artificial-owl.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
@@ -29,21 +30,21 @@ namespace OCA\Files_Sharing\BackgroundJob;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
use OCP\IDBConnection;
+use OCP\OCM\Exceptions\OCMProviderException;
+use OCP\OCM\IOCMDiscoveryService;
use OCP\OCS\IDiscoveryService;
+use Psr\Log\LoggerInterface;
class FederatedSharesDiscoverJob extends TimedJob {
- /** @var IDBConnection */
- private $connection;
- /** @var IDiscoveryService */
- private $discoveryService;
-
- public function __construct(ITimeFactory $time,
- IDBConnection $connection,
- IDiscoveryService $discoveryService) {
- parent::__construct($time);
- $this->connection = $connection;
- $this->discoveryService = $discoveryService;
+ public function __construct(
+ ITimeFactory $time,
+ private IDBConnection $connection,
+ private IDiscoveryService $discoveryService,
+ private IOCMDiscoveryService $ocmDiscoveryService,
+ private LoggerInterface $logger,
+ ) {
+ parent::__construct($time);
$this->setInterval(86400);
}
@@ -56,6 +57,11 @@ class FederatedSharesDiscoverJob extends TimedJob {
$result = $qb->execute();
while ($row = $result->fetch()) {
$this->discoveryService->discover($row['remote'], 'FEDERATED_SHARING', true);
+ try {
+ $this->ocmDiscoveryService->discover($row['remote'], true);
+ } catch (OCMProviderException $e) {
+ $this->logger->info('exception while running files_sharing/lib/BackgroundJob/FederatedSharesDiscoverJob', ['exception' => $e]);
+ }
}
$result->closeCursor();
}
diff --git a/apps/files_sharing/lib/Cache.php b/apps/files_sharing/lib/Cache.php
index 594660661ca..5160b7e821a 100644
--- a/apps/files_sharing/lib/Cache.php
+++ b/apps/files_sharing/lib/Cache.php
@@ -28,19 +28,19 @@
*/
namespace OCA\Files_Sharing;
+use OC\Files\Cache\CacheDependencies;
use OC\Files\Cache\FailedCache;
use OC\Files\Cache\Wrapper\CacheJail;
use OC\Files\Search\SearchBinaryOperator;
use OC\Files\Search\SearchComparison;
use OC\Files\Storage\Wrapper\Jail;
use OC\User\DisplayNameCache;
+use OCP\Files\Cache\ICache;
use OCP\Files\Cache\ICacheEntry;
use OCP\Files\Search\ISearchBinaryOperator;
use OCP\Files\Search\ISearchComparison;
use OCP\Files\Search\ISearchOperator;
use OCP\Files\StorageNotAvailableException;
-use OCP\ICacheFactory;
-use OCP\IUserManager;
use OCP\Share\IShare;
/**
@@ -64,18 +64,19 @@ class Cache extends CacheJail {
public function __construct(
$storage,
ICacheEntry $sourceRootInfo,
- DisplayNameCache $displayNameCache,
+ CacheDependencies $dependencies,
IShare $share
) {
$this->storage = $storage;
$this->sourceRootInfo = $sourceRootInfo;
$this->numericId = $sourceRootInfo->getStorageId();
- $this->displayNameCache = $displayNameCache;
+ $this->displayNameCache = $dependencies->getDisplayNameCache();
$this->share = $share;
parent::__construct(
null,
- ''
+ '',
+ $dependencies,
);
}
@@ -100,7 +101,7 @@ class Cache extends CacheJail {
return $this->sourceRootInfo->getPath();
}
- public function getCache() {
+ public function getCache(): ICache {
if (is_null($this->cache)) {
$sourceStorage = $this->storage->getSourceStorage();
if ($sourceStorage) {
@@ -162,6 +163,10 @@ class Cache extends CacheJail {
} else {
$entry['permissions'] = $this->storage->getPermissions($entry['path']);
}
+
+ if ($this->share->getNodeId() === $entry['fileid']) {
+ $entry['name'] = basename($this->share->getTarget());
+ }
} catch (StorageNotAvailableException $e) {
// thrown by FailedStorage e.g. when the sharer does not exist anymore
// (IDE may say the exception is never thrown – false negative)
diff --git a/apps/files_sharing/lib/Collaboration/ShareRecipientSorter.php b/apps/files_sharing/lib/Collaboration/ShareRecipientSorter.php
index 2fd35b20a0f..4ed30f44020 100644
--- a/apps/files_sharing/lib/Collaboration/ShareRecipientSorter.php
+++ b/apps/files_sharing/lib/Collaboration/ShareRecipientSorter.php
@@ -24,7 +24,6 @@
namespace OCA\Files_Sharing\Collaboration;
use OCP\Collaboration\AutoComplete\ISorter;
-use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Files\Node;
use OCP\IUserSession;
diff --git a/apps/files_sharing/lib/Command/DeleteOrphanShares.php b/apps/files_sharing/lib/Command/DeleteOrphanShares.php
index 310f27ebfa3..57158774758 100644
--- a/apps/files_sharing/lib/Command/DeleteOrphanShares.php
+++ b/apps/files_sharing/lib/Command/DeleteOrphanShares.php
@@ -23,14 +23,13 @@ declare(strict_types=1);
namespace OCA\Files_Sharing\Command;
-
-use Symfony\Component\Console\Question\ConfirmationQuestion;
use OC\Core\Command\Base;
use OCA\Files_Sharing\OrphanHelper;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Question\ConfirmationQuestion;
class DeleteOrphanShares extends Base {
private OrphanHelper $orphanHelper;
diff --git a/apps/files_sharing/lib/Command/ExiprationNotification.php b/apps/files_sharing/lib/Command/ExiprationNotification.php
index e77b41b1835..b0311e09221 100644
--- a/apps/files_sharing/lib/Command/ExiprationNotification.php
+++ b/apps/files_sharing/lib/Command/ExiprationNotification.php
@@ -46,9 +46,9 @@ class ExiprationNotification extends Command {
private $shareManager;
public function __construct(ITimeFactory $time,
- NotificationManager $notificationManager,
- IDBConnection $connection,
- ShareManager $shareManager) {
+ NotificationManager $notificationManager,
+ IDBConnection $connection,
+ ShareManager $shareManager) {
parent::__construct();
$this->notificationManager = $notificationManager;
@@ -67,7 +67,7 @@ class ExiprationNotification extends Command {
//Current time
$minTime = $this->time->getDateTime();
$minTime->add(new \DateInterval('P1D'));
- $minTime->setTime(0,0,0);
+ $minTime->setTime(0, 0, 0);
$maxTime = clone $minTime;
$maxTime->setTime(23, 59, 59);
diff --git a/apps/files_sharing/lib/Controller/AcceptController.php b/apps/files_sharing/lib/Controller/AcceptController.php
index 60bdaf519be..603f0089ba8 100644
--- a/apps/files_sharing/lib/Controller/AcceptController.php
+++ b/apps/files_sharing/lib/Controller/AcceptController.php
@@ -28,7 +28,7 @@ namespace OCA\Files_Sharing\Controller;
use OCA\Files_Sharing\AppInfo\Application;
use OCP\AppFramework\Controller;
-use OCP\AppFramework\Http\Attribute\IgnoreOpenAPI;
+use OCP\AppFramework\Http\Attribute\OpenAPI;
use OCP\AppFramework\Http\NotFoundResponse;
use OCP\AppFramework\Http\RedirectResponse;
use OCP\AppFramework\Http\Response;
@@ -38,7 +38,7 @@ use OCP\IUserSession;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager as ShareManager;
-#[IgnoreOpenAPI]
+#[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)]
class AcceptController extends Controller {
/** @var ShareManager */
diff --git a/apps/files_sharing/lib/Controller/DeletedShareAPIController.php b/apps/files_sharing/lib/Controller/DeletedShareAPIController.php
index ddd3816022e..6b54a3489c6 100644
--- a/apps/files_sharing/lib/Controller/DeletedShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/DeletedShareAPIController.php
@@ -51,7 +51,7 @@ use OCP\Share\IManager as ShareManager;
use OCP\Share\IShare;
/**
- * @psalm-import-type FilesSharingDeletedShare from ResponseDefinitions
+ * @psalm-import-type Files_SharingDeletedShare from ResponseDefinitions
*/
class DeletedShareAPIController extends OCSController {
@@ -77,14 +77,14 @@ class DeletedShareAPIController extends OCSController {
private $serverContainer;
public function __construct(string $appName,
- IRequest $request,
- ShareManager $shareManager,
- string $UserId,
- IUserManager $userManager,
- IGroupManager $groupManager,
- IRootFolder $rootFolder,
- IAppManager $appManager,
- IServerContainer $serverContainer) {
+ IRequest $request,
+ ShareManager $shareManager,
+ string $UserId,
+ IUserManager $userManager,
+ IGroupManager $groupManager,
+ IRootFolder $rootFolder,
+ IAppManager $appManager,
+ IServerContainer $serverContainer) {
parent::__construct($appName, $request);
$this->shareManager = $shareManager;
@@ -99,7 +99,7 @@ class DeletedShareAPIController extends OCSController {
/**
* @suppress PhanUndeclaredClassMethod
*
- * @return FilesSharingDeletedShare
+ * @return Files_SharingDeletedShare
*/
private function formatShare(IShare $share): array {
$result = [
@@ -187,7 +187,9 @@ class DeletedShareAPIController extends OCSController {
*
* Get a list of all deleted shares
*
- * @return DataResponse<Http::STATUS_OK, FilesSharingDeletedShare[], array{}>
+ * @return DataResponse<Http::STATUS_OK, Files_SharingDeletedShare[], array{}>
+ *
+ * 200: Deleted shares returned
*/
public function index(): DataResponse {
$groupShares = $this->shareManager->getDeletedSharedWith($this->userId, IShare::TYPE_GROUP, null, -1, 0);
diff --git a/apps/files_sharing/lib/Controller/ExternalSharesController.php b/apps/files_sharing/lib/Controller/ExternalSharesController.php
index 4cd09423eaa..726e99345fa 100644
--- a/apps/files_sharing/lib/Controller/ExternalSharesController.php
+++ b/apps/files_sharing/lib/Controller/ExternalSharesController.php
@@ -29,6 +29,7 @@ use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\JSONResponse;
use OCP\Http\Client\IClientService;
+use OCP\IConfig;
use OCP\IRequest;
/**
@@ -37,25 +38,14 @@ use OCP\IRequest;
* @package OCA\Files_Sharing\Controller
*/
class ExternalSharesController extends Controller {
-
- /** @var \OCA\Files_Sharing\External\Manager */
- private $externalManager;
- /** @var IClientService */
- private $clientService;
-
- /**
- * @param string $appName
- * @param IRequest $request
- * @param \OCA\Files_Sharing\External\Manager $externalManager
- * @param IClientService $clientService
- */
- public function __construct($appName,
- IRequest $request,
- \OCA\Files_Sharing\External\Manager $externalManager,
- IClientService $clientService) {
+ public function __construct(
+ string $appName,
+ IRequest $request,
+ private \OCA\Files_Sharing\External\Manager $externalManager,
+ private IClientService $clientService,
+ private IConfig $config,
+ ) {
parent::__construct($appName, $request);
- $this->externalManager = $externalManager;
- $this->clientService = $clientService;
}
/**
@@ -107,6 +97,7 @@ class ExternalSharesController extends Controller {
[
'timeout' => 3,
'connect_timeout' => 3,
+ 'verify' => !$this->config->getSystemValueBool('sharing.federation.allowSelfSignedCertificates', false),
]
)->getBody());
@@ -134,14 +125,14 @@ class ExternalSharesController extends Controller {
}
if (
- $this->testUrl('https://' . $remote . '/ocs-provider/') ||
- $this->testUrl('https://' . $remote . '/ocs-provider/index.php') ||
+ $this->testUrl('https://' . $remote . '/ocm-provider/') ||
+ $this->testUrl('https://' . $remote . '/ocm-provider/index.php') ||
$this->testUrl('https://' . $remote . '/status.php', true)
) {
return new DataResponse('https');
} elseif (
- $this->testUrl('http://' . $remote . '/ocs-provider/') ||
- $this->testUrl('http://' . $remote . '/ocs-provider/index.php') ||
+ $this->testUrl('http://' . $remote . '/ocm-provider/') ||
+ $this->testUrl('http://' . $remote . '/ocm-provider/index.php') ||
$this->testUrl('http://' . $remote . '/status.php', true)
) {
return new DataResponse('http');
diff --git a/apps/files_sharing/lib/Controller/PublicPreviewController.php b/apps/files_sharing/lib/Controller/PublicPreviewController.php
index 089610f711f..c59baac73c4 100644
--- a/apps/files_sharing/lib/Controller/PublicPreviewController.php
+++ b/apps/files_sharing/lib/Controller/PublicPreviewController.php
@@ -51,17 +51,17 @@ class PublicPreviewController extends PublicShareController {
private $share;
public function __construct(string $appName,
- IRequest $request,
- ShareManager $shareManger,
- ISession $session,
- IPreview $previewManager) {
+ IRequest $request,
+ ShareManager $shareManger,
+ ISession $session,
+ IPreview $previewManager) {
parent::__construct($appName, $request, $session);
$this->shareManager = $shareManger;
$this->previewManager = $previewManager;
}
- protected function getPasswordHash(): string {
+ protected function getPasswordHash(): ?string {
return $this->share->getPassword();
}
diff --git a/apps/files_sharing/lib/Controller/RemoteController.php b/apps/files_sharing/lib/Controller/RemoteController.php
index 70cb55cae15..b507bf6a04a 100644
--- a/apps/files_sharing/lib/Controller/RemoteController.php
+++ b/apps/files_sharing/lib/Controller/RemoteController.php
@@ -35,7 +35,7 @@ use OCP\IRequest;
use Psr\Log\LoggerInterface;
/**
- * @psalm-import-type FilesSharingRemoteShare from ResponseDefinitions
+ * @psalm-import-type Files_SharingRemoteShare from ResponseDefinitions
*/
class RemoteController extends OCSController {
/**
@@ -61,7 +61,9 @@ class RemoteController extends OCSController {
*
* Get list of pending remote shares
*
- * @return DataResponse<Http::STATUS_OK, FilesSharingRemoteShare[], array{}>
+ * @return DataResponse<Http::STATUS_OK, Files_SharingRemoteShare[], array{}>
+ *
+ * 200: Pending remote shares returned
*/
public function getOpenShares() {
return new DataResponse($this->externalManager->getOpenShares());
@@ -137,7 +139,9 @@ class RemoteController extends OCSController {
*
* Get a list of accepted remote shares
*
- * @return DataResponse<Http::STATUS_OK, FilesSharingRemoteShare[], array{}>
+ * @return DataResponse<Http::STATUS_OK, Files_SharingRemoteShare[], array{}>
+ *
+ * 200: Accepted remote shares returned
*/
public function getShares() {
$shares = $this->externalManager->getAcceptedShares();
@@ -152,7 +156,7 @@ class RemoteController extends OCSController {
* Get info of a remote share
*
* @param int $id ID of the share
- * @return DataResponse<Http::STATUS_OK, FilesSharingRemoteShare, array{}>
+ * @return DataResponse<Http::STATUS_OK, Files_SharingRemoteShare, array{}>
* @throws OCSNotFoundException Share not found
*
* 200: Share returned
diff --git a/apps/files_sharing/lib/Controller/SettingsController.php b/apps/files_sharing/lib/Controller/SettingsController.php
index 00d627095b8..ff087d4a196 100644
--- a/apps/files_sharing/lib/Controller/SettingsController.php
+++ b/apps/files_sharing/lib/Controller/SettingsController.php
@@ -41,8 +41,8 @@ class SettingsController extends Controller {
private $userId;
public function __construct(IRequest $request,
- IConfig $config,
- string $userId) {
+ IConfig $config,
+ string $userId) {
parent::__construct(Application::APP_ID, $request);
$this->config = $config;
diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php
index b2a2e774766..5bb1581b6ab 100644
--- a/apps/files_sharing/lib/Controller/ShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareAPIController.php
@@ -70,6 +70,7 @@ use OCP\Files\IRootFolder;
use OCP\Files\Node;
use OCP\Files\NotFoundException;
use OCP\IConfig;
+use OCP\IDateTimeZone;
use OCP\IGroupManager;
use OCP\IL10N;
use OCP\IPreview;
@@ -91,7 +92,7 @@ use Psr\Log\LoggerInterface;
/**
* @package OCA\Files_Sharing\API
*
- * @psalm-import-type FilesSharingShare from ResponseDefinitions
+ * @psalm-import-type Files_SharingShare from ResponseDefinitions
*/
class ShareAPIController extends OCSController {
@@ -124,20 +125,6 @@ class ShareAPIController extends OCSController {
/**
* Share20OCS constructor.
- *
- * @param string $appName
- * @param IRequest $request
- * @param IManager $shareManager
- * @param IGroupManager $groupManager
- * @param IUserManager $userManager
- * @param IRootFolder $rootFolder
- * @param IURLGenerator $urlGenerator
- * @param string $userId
- * @param IL10N $l10n
- * @param IConfig $config
- * @param IAppManager $appManager
- * @param IServerContainer $serverContainer
- * @param IUserStatusManager $userStatusManager
*/
public function __construct(
string $appName,
@@ -153,7 +140,8 @@ class ShareAPIController extends OCSController {
IAppManager $appManager,
IServerContainer $serverContainer,
IUserStatusManager $userStatusManager,
- IPreview $previewManager
+ IPreview $previewManager,
+ private IDateTimeZone $dateTimeZone,
) {
parent::__construct($appName, $request);
@@ -177,7 +165,7 @@ class ShareAPIController extends OCSController {
*
* @param \OCP\Share\IShare $share
* @param Node|null $recipientNode
- * @return FilesSharingShare
+ * @return Files_SharingShare
* @throws NotFoundException In case the node can't be resolved.
*
* @suppress PhanUndeclaredClassMethod
@@ -260,7 +248,7 @@ class ShareAPIController extends OCSController {
$result['share_with'] = $share->getSharedWith();
$result['share_with_displayname'] = $sharedWith !== null ? $sharedWith->getDisplayName() : $share->getSharedWith();
$result['share_with_displayname_unique'] = $sharedWith !== null ? (
- !empty($sharedWith->getSystemEMailAddress()) ? $sharedWith->getSystemEMailAddress() : $sharedWith->getUID()
+ !empty($sharedWith->getSystemEMailAddress()) ? $sharedWith->getSystemEMailAddress() : $sharedWith->getUID()
) : $share->getSharedWith();
$userStatuses = $this->userStatusManager->getUserStatuses([$share->getSharedWith()]);
@@ -322,10 +310,11 @@ class ShareAPIController extends OCSController {
$shareWithStart = ($hasCircleId ? strrpos($share->getSharedWith(), '[') + 1 : 0);
$shareWithLength = ($hasCircleId ? -1 : strpos($share->getSharedWith(), ' '));
- if (is_bool($shareWithLength)) {
- $shareWithLength = -1;
+ if ($shareWithLength === false) {
+ $result['share_with'] = substr($share->getSharedWith(), $shareWithStart);
+ } else {
+ $result['share_with'] = substr($share->getSharedWith(), $shareWithStart, $shareWithLength);
}
- $result['share_with'] = substr($share->getSharedWith(), $shareWithStart, $shareWithLength);
} elseif ($share->getShareType() === IShare::TYPE_ROOM) {
$result['share_with'] = $share->getSharedWith();
$result['share_with_displayname'] = '';
@@ -364,7 +353,7 @@ class ShareAPIController extends OCSController {
$result['attributes'] = null;
if ($attributes = $share->getAttributes()) {
- $result['attributes'] = (string)\json_encode($attributes->toArray());
+ $result['attributes'] = (string)\json_encode($attributes->toArray());
}
return $result;
@@ -508,7 +497,7 @@ class ShareAPIController extends OCSController {
*
* @param string $id ID of the share
* @param bool $include_tags Include tags in the share
- * @return DataResponse<Http::STATUS_OK, FilesSharingShare, array{}>
+ * @return DataResponse<Http::STATUS_OK, Files_SharingShare, array{}>
* @throws OCSNotFoundException Share not found
*
* 200: Share returned
@@ -597,12 +586,12 @@ class ShareAPIController extends OCSController {
* @param string $publicUpload If public uploading is allowed
* @param string $password Password for the share
* @param string|null $sendPasswordByTalk Send the password for the share over Talk
- * @param string $expireDate Expiry date of the share
+ * @param string $expireDate Expiry date of the share using user timezone at 00:00. It means date in UTC timezone will be used.
* @param string $note Note for the share
* @param string $label Label for the share (only used in link and email)
* @param string|null $attributes Additional attributes for the share
*
- * @return DataResponse<Http::STATUS_OK, FilesSharingShare, array{}>
+ * @return DataResponse<Http::STATUS_OK, Files_SharingShare, array{}>
* @throws OCSBadRequestException Unknown share type
* @throws OCSException
* @throws OCSForbiddenException Creating the share is not allowed
@@ -699,7 +688,7 @@ class ShareAPIController extends OCSController {
if ($shareType === IShare::TYPE_USER) {
// Valid user is required to share
if ($shareWith === null || !$this->userManager->userExists($shareWith)) {
- throw new OCSNotFoundException($this->l->t('Please specify a valid user'));
+ throw new OCSNotFoundException($this->l->t('Please specify a valid account to share with'));
}
$share->setSharedWith($shareWith);
$share->setPermissions($permissions);
@@ -774,7 +763,7 @@ class ShareAPIController extends OCSController {
}
if ($shareWith === null) {
- throw new OCSNotFoundException($this->l->t('Please specify a valid federated user ID'));
+ throw new OCSNotFoundException($this->l->t('Please specify a valid federated account ID'));
}
$share->setSharedWith($shareWith);
@@ -862,11 +851,11 @@ class ShareAPIController extends OCSController {
try {
$share = $this->shareManager->createShare($share);
} catch (GenericShareException $e) {
- \OC::$server->getLogger()->logException($e);
+ \OCP\Server::get(LoggerInterface::class)->error($e->getMessage(), ['exception' => $e]);
$code = $e->getCode() === 0 ? 403 : $e->getCode();
throw new OCSException($e->getHint(), $code);
} catch (\Exception $e) {
- \OC::$server->getLogger()->logException($e);
+ \OCP\Server::get(LoggerInterface::class)->error($e->getMessage(), ['exception' => $e]);
throw new OCSForbiddenException($e->getMessage(), $e);
}
@@ -879,7 +868,7 @@ class ShareAPIController extends OCSController {
* @param null|Node $node
* @param boolean $includeTags
*
- * @return FilesSharingShare[]
+ * @return Files_SharingShare[]
*/
private function getSharedWithMe($node, bool $includeTags): array {
$userShares = $this->shareManager->getSharedWith($this->currentUser, IShare::TYPE_USER, $node, -1, 0);
@@ -916,7 +905,7 @@ class ShareAPIController extends OCSController {
/**
* @param \OCP\Files\Node $folder
*
- * @return FilesSharingShare[]
+ * @return Files_SharingShare[]
* @throws OCSBadRequestException
* @throws NotFoundException
*/
@@ -978,7 +967,7 @@ class ShareAPIController extends OCSController {
* @param string $path Get shares for a specific path
* @param string $include_tags Include tags in the share
*
- * @return DataResponse<Http::STATUS_OK, FilesSharingShare[], array{}>
+ * @return DataResponse<Http::STATUS_OK, Files_SharingShare[], array{}>
* @throws OCSNotFoundException The folder was not found or is inaccessible
*
* 200: Shares returned
@@ -1026,7 +1015,7 @@ class ShareAPIController extends OCSController {
* @param bool $subFiles
* @param bool $includeTags
*
- * @return FilesSharingShare[]
+ * @return Files_SharingShare[]
* @throws NotFoundException
* @throws OCSBadRequestException
*/
@@ -1111,7 +1100,7 @@ class ShareAPIController extends OCSController {
*
* @param string $path Path all shares will be relative to
*
- * @return DataResponse<Http::STATUS_OK, FilesSharingShare[], array{}>
+ * @return DataResponse<Http::STATUS_OK, Files_SharingShare[], array{}>
* @throws InvalidPathException
* @throws NotFoundException
* @throws OCSNotFoundException The given path is invalid
@@ -1213,7 +1202,7 @@ class ShareAPIController extends OCSController {
* @param string|null $label New label
* @param string|null $hideDownload New condition if the download should be hidden
* @param string|null $attributes New additional attributes
- * @return DataResponse<Http::STATUS_OK, FilesSharingShare, array{}>
+ * @return DataResponse<Http::STATUS_OK, Files_SharingShare, array{}>
* @throws OCSBadRequestException Share could not be updated because the requested changes are invalid
* @throws OCSForbiddenException Missing permissions to update the share
* @throws OCSNotFoundException Share not found
@@ -1314,8 +1303,8 @@ class ShareAPIController extends OCSController {
}
if (!$this->hasPermission($newPermissions, Constants::PERMISSION_READ) && (
- $this->hasPermission($newPermissions, Constants::PERMISSION_UPDATE) || $this->hasPermission($newPermissions, Constants::PERMISSION_DELETE)
- )) {
+ $this->hasPermission($newPermissions, Constants::PERMISSION_UPDATE) || $this->hasPermission($newPermissions, Constants::PERMISSION_DELETE)
+ )) {
throw new OCSBadRequestException($this->l->t('Share must have READ permission if UPDATE or DELETE permission is set'));
}
}
@@ -1409,7 +1398,9 @@ class ShareAPIController extends OCSController {
*
* Get all shares that are still pending
*
- * @return DataResponse<Http::STATUS_OK, FilesSharingShare[], array{}>
+ * @return DataResponse<Http::STATUS_OK, Files_SharingShare[], array{}>
+ *
+ * 200: Pending shares returned
*/
public function pendingShares(): DataResponse {
$pendingShares = [];
@@ -1704,11 +1695,12 @@ class ShareAPIController extends OCSController {
*/
private function parseDate(string $expireDate): \DateTime {
try {
- $date = new \DateTime(trim($expireDate, "\""));
+ $date = new \DateTime(trim($expireDate, "\""), $this->dateTimeZone->getTimeZone());
} catch (\Exception $e) {
throw new \Exception('Invalid date. Format must be YYYY-MM-DD');
}
+ $date->setTimezone(new \DateTimeZone(date_default_timezone_get()));
$date->setTime(0, 0, 0);
return $date;
diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php
index dc60463dac7..0691137631b 100644
--- a/apps/files_sharing/lib/Controller/ShareController.php
+++ b/apps/files_sharing/lib/Controller/ShareController.php
@@ -46,13 +46,14 @@ namespace OCA\Files_Sharing\Controller;
use OC\Security\CSP\ContentSecurityPolicy;
use OC_Files;
use OC_Util;
+use OCA\DAV\Connector\Sabre\PublicAuth;
use OCA\FederatedFileSharing\FederatedShareProvider;
use OCA\Files_Sharing\Activity\Providers\Downloads;
use OCA\Files_Sharing\Event\BeforeTemplateRenderedEvent;
use OCA\Files_Sharing\Event\ShareLinkAccessedEvent;
use OCP\Accounts\IAccountManager;
use OCP\AppFramework\AuthPublicShareController;
-use OCP\AppFramework\Http\Attribute\IgnoreOpenAPI;
+use OCP\AppFramework\Http\Attribute\OpenAPI;
use OCP\AppFramework\Http\NotFoundResponse;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\Defaults;
@@ -71,14 +72,14 @@ use OCP\Security\ISecureRandom;
use OCP\Share;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager as ShareManager;
-use OCP\Share\IShare;
use OCP\Share\IPublicShareTemplateFactory;
+use OCP\Share\IShare;
use OCP\Template;
/**
* @package OCA\Files_Sharing\Controllers
*/
-#[IgnoreOpenAPI]
+#[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)]
class ShareController extends AuthPublicShareController {
protected ?Share\IShare $share = null;
@@ -203,7 +204,7 @@ class ShareController extends AuthPublicShareController {
return $this->shareManager->checkPassword($this->share, $password);
}
- protected function getPasswordHash(): string {
+ protected function getPasswordHash(): ?string {
return $this->share->getPassword();
}
@@ -222,8 +223,12 @@ class ShareController extends AuthPublicShareController {
}
protected function authSucceeded() {
+ if ($this->share === null) {
+ throw new NotFoundException();
+ }
+
// For share this was always set so it is still used in other apps
- $this->session->set('public_link_authenticated', (string)$this->share->getId());
+ $this->session->set(PublicAuth::DAV_AUTHENTICATED, $this->share->getId());
}
protected function authFailed() {
@@ -569,10 +574,10 @@ class ShareController extends AuthPublicShareController {
* @param string $filePath
*/
protected function publishActivity($subject,
- array $parameters,
- $affectedUser,
- $fileId,
- $filePath) {
+ array $parameters,
+ $affectedUser,
+ $fileId,
+ $filePath) {
$event = $this->activityManager->generateEvent();
$event->setApp('files_sharing')
->setType('public_links')
diff --git a/apps/files_sharing/lib/Controller/ShareInfoController.php b/apps/files_sharing/lib/Controller/ShareInfoController.php
index 14f69b9703f..a1379a63d9a 100644
--- a/apps/files_sharing/lib/Controller/ShareInfoController.php
+++ b/apps/files_sharing/lib/Controller/ShareInfoController.php
@@ -38,7 +38,7 @@ use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager;
/**
- * @psalm-import-type FilesSharingShareInfo from ResponseDefinitions
+ * @psalm-import-type Files_SharingShareInfo from ResponseDefinitions
*/
class ShareInfoController extends ApiController {
@@ -53,8 +53,8 @@ class ShareInfoController extends ApiController {
* @param IManager $shareManager
*/
public function __construct(string $appName,
- IRequest $request,
- IManager $shareManager) {
+ IRequest $request,
+ IManager $shareManager) {
parent::__construct($appName, $request);
$this->shareManager = $shareManager;
@@ -71,7 +71,7 @@ class ShareInfoController extends ApiController {
* @param string|null $password Password of the share
* @param string|null $dir Subdirectory to get info about
* @param int $depth Maximum depth to get info about
- * @return JSONResponse<Http::STATUS_OK, FilesSharingShareInfo, array{}>|JSONResponse<Http::STATUS_FORBIDDEN|Http::STATUS_NOT_FOUND, array<empty>, array{}>
+ * @return JSONResponse<Http::STATUS_OK, Files_SharingShareInfo, array{}>|JSONResponse<Http::STATUS_FORBIDDEN|Http::STATUS_NOT_FOUND, array<empty>, array{}>
*
* 200: Share info returned
* 403: Getting share info is not allowed
@@ -112,7 +112,7 @@ class ShareInfoController extends ApiController {
}
/**
- * @return FilesSharingShareInfo
+ * @return Files_SharingShareInfo
*/
private function parseNode(Node $node, int $permissionMask, int $depth): array {
if ($node instanceof File) {
@@ -123,14 +123,14 @@ class ShareInfoController extends ApiController {
}
/**
- * @return FilesSharingShareInfo
+ * @return Files_SharingShareInfo
*/
private function parseFile(File $file, int $permissionMask): array {
return $this->format($file, $permissionMask);
}
/**
- * @return FilesSharingShareInfo
+ * @return Files_SharingShareInfo
*/
private function parseFolder(Folder $folder, int $permissionMask, int $depth): array {
$data = $this->format($folder, $permissionMask);
@@ -150,7 +150,7 @@ class ShareInfoController extends ApiController {
}
/**
- * @return FilesSharingShareInfo
+ * @return Files_SharingShareInfo
*/
private function format(Node $node, int $permissionMask): array {
$entry = [];
diff --git a/apps/files_sharing/lib/Controller/ShareesAPIController.php b/apps/files_sharing/lib/Controller/ShareesAPIController.php
index a9288be9386..00bc85e4a96 100644
--- a/apps/files_sharing/lib/Controller/ShareesAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareesAPIController.php
@@ -38,9 +38,6 @@ declare(strict_types=1);
*/
namespace OCA\Files_Sharing\Controller;
-use OCP\Constants;
-use function array_slice;
-use function array_values;
use Generator;
use OC\Collaboration\Collaborators\SearchResult;
use OCA\Files_Sharing\ResponseDefinitions;
@@ -51,16 +48,19 @@ use OCP\AppFramework\OCSController;
use OCP\Collaboration\Collaborators\ISearch;
use OCP\Collaboration\Collaborators\ISearchResult;
use OCP\Collaboration\Collaborators\SearchResultType;
+use OCP\Constants;
use OCP\IConfig;
use OCP\IRequest;
use OCP\IURLGenerator;
-use OCP\Share\IShare;
use OCP\Share\IManager;
+use OCP\Share\IShare;
+use function array_slice;
+use function array_values;
use function usort;
/**
- * @psalm-import-type FilesSharingShareesSearchResult from ResponseDefinitions
- * @psalm-import-type FilesSharingShareesRecommendedResult from ResponseDefinitions
+ * @psalm-import-type Files_SharingShareesSearchResult from ResponseDefinitions
+ * @psalm-import-type Files_SharingShareesRecommendedResult from ResponseDefinitions
*/
class ShareesAPIController extends OCSController {
@@ -82,7 +82,7 @@ class ShareesAPIController extends OCSController {
/** @var int */
protected $limit = 10;
- /** @var FilesSharingShareesSearchResult */
+ /** @var Files_SharingShareesSearchResult */
protected $result = [
'exact' => [
'users' => [],
@@ -145,7 +145,7 @@ class ShareesAPIController extends OCSController {
* @param int $perPage Limit amount of search results per page
* @param int|int[]|null $shareType Limit to specific share types
* @param bool $lookup If a global lookup should be performed too
- * @return DataResponse<Http::STATUS_OK, FilesSharingShareesSearchResult, array{Link?: string}>
+ * @return DataResponse<Http::STATUS_OK, Files_SharingShareesSearchResult, array{Link?: string}>
* @throws OCSBadRequestException Invalid search parameters
*
* 200: Sharees search result returned
@@ -347,7 +347,9 @@ class ShareesAPIController extends OCSController {
*
* @param string $itemType Limit to specific item types
* @param int|int[]|null $shareType Limit to specific share types
- * @return DataResponse<Http::STATUS_OK, FilesSharingShareesRecommendedResult, array{}>
+ * @return DataResponse<Http::STATUS_OK, Files_SharingShareesRecommendedResult, array{}>
+ *
+ * 200: Recommended sharees returned
*/
public function findRecommended(string $itemType, $shareType = null): DataResponse {
$shareTypes = [
diff --git a/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php b/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php
index 9c95428d7b7..8af1c803e18 100644
--- a/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php
+++ b/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php
@@ -39,7 +39,6 @@ use OCP\Defaults;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\FileInfo;
use OCP\Files\Folder;
-use OCP\Files\NotFoundException;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IPreview;
@@ -47,8 +46,8 @@ use OCP\IRequest;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserManager;
-use OCP\Share\IShare;
use OCP\Share\IPublicShareTemplateProvider;
+use OCP\Share\IShare;
use OCP\Template;
use OCP\Util;
diff --git a/apps/files_sharing/lib/DeleteOrphanedSharesJob.php b/apps/files_sharing/lib/DeleteOrphanedSharesJob.php
index d2cc39ff060..6883bfd4762 100644
--- a/apps/files_sharing/lib/DeleteOrphanedSharesJob.php
+++ b/apps/files_sharing/lib/DeleteOrphanedSharesJob.php
@@ -26,25 +26,22 @@ namespace OCA\Files_Sharing;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
+use OCP\IDBConnection;
+use OCP\Server;
+use Psr\Log\LoggerInterface;
/**
* Delete all share entries that have no matching entries in the file cache table.
*/
class DeleteOrphanedSharesJob extends TimedJob {
/**
- * Default interval in minutes
- *
- * @var int $defaultIntervalMin
- **/
- protected $defaultIntervalMin = 15;
-
- /**
* sets the correct interval for this timed job
*/
public function __construct(ITimeFactory $time) {
parent::__construct($time);
- $this->interval = $this->defaultIntervalMin * 60;
+ $this->setInterval(24 * 60 * 60); // 1 day
+ $this->setTimeSensitivity(self::TIME_INSENSITIVE);
}
/**
@@ -53,15 +50,15 @@ class DeleteOrphanedSharesJob extends TimedJob {
* @param array $argument unused argument
*/
public function run($argument) {
- $connection = \OC::$server->getDatabaseConnection();
- $logger = \OC::$server->getLogger();
+ $connection = Server::get(IDBConnection::class);
+ $logger = Server::get(LoggerInterface::class);
$sql =
'DELETE FROM `*PREFIX*share` ' .
'WHERE `item_type` in (\'file\', \'folder\') ' .
'AND NOT EXISTS (SELECT `fileid` FROM `*PREFIX*filecache` WHERE `file_source` = `fileid`)';
- $deletedEntries = $connection->executeUpdate($sql);
+ $deletedEntries = $connection->executeStatement($sql);
$logger->debug("$deletedEntries orphaned share(s) deleted", ['app' => 'DeleteOrphanedSharesJob']);
}
}
diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php
index d2e113c8bb3..f18d8346dc4 100644
--- a/apps/files_sharing/lib/External/Manager.php
+++ b/apps/files_sharing/lib/External/Manager.php
@@ -472,7 +472,7 @@ class Manager {
}
$federationEndpoints = $this->discoveryService->discover($remote, 'FEDERATED_SHARING');
- $endpoint = isset($federationEndpoints['share']) ? $federationEndpoints['share'] : '/ocs/v2.php/cloud/shares';
+ $endpoint = $federationEndpoints['share'] ?? '/ocs/v2.php/cloud/shares';
$url = rtrim($remote, '/') . $endpoint . '/' . $remoteId . '/' . $feedback . '?format=' . Share::RESPONSE_FORMAT;
$fields = ['token' => $token];
@@ -606,6 +606,10 @@ class Manager {
$this->logger->error('Mount point to remove share not found', ['mountPoint' => $mountPoint]);
return false;
}
+ if (!$mountPointObj instanceof Mount) {
+ $this->logger->error('Mount point to remove share is not an external share, share probably doesn\'t exist', ['mountPoint' => $mountPoint]);
+ return false;
+ }
$id = $mountPointObj->getStorage()->getCache()->getId('');
$mountPoint = $this->stripPath($mountPoint);
diff --git a/apps/files_sharing/lib/External/Mount.php b/apps/files_sharing/lib/External/Mount.php
index ccd31147f26..283027ac43a 100644
--- a/apps/files_sharing/lib/External/Mount.php
+++ b/apps/files_sharing/lib/External/Mount.php
@@ -26,8 +26,9 @@ namespace OCA\Files_Sharing\External;
use OC\Files\Mount\MountPoint;
use OC\Files\Mount\MoveableMount;
+use OCA\Files_Sharing\ISharedMountPoint;
-class Mount extends MountPoint implements MoveableMount {
+class Mount extends MountPoint implements MoveableMount, ISharedMountPoint {
/**
* @var \OCA\Files_Sharing\External\Manager
diff --git a/apps/files_sharing/lib/External/MountProvider.php b/apps/files_sharing/lib/External/MountProvider.php
index 5b315e81f69..169bf6ed3d7 100644
--- a/apps/files_sharing/lib/External/MountProvider.php
+++ b/apps/files_sharing/lib/External/MountProvider.php
@@ -24,11 +24,11 @@
*/
namespace OCA\Files_Sharing\External;
+use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\Federation\ICloudIdManager;
use OCP\Files\Config\IMountProvider;
use OCP\Files\Storage\IStorageFactory;
use OCP\IDBConnection;
-use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IUser;
class MountProvider implements IMountProvider {
diff --git a/apps/files_sharing/lib/External/Storage.php b/apps/files_sharing/lib/External/Storage.php
index 9e6c169e140..7b64690d53e 100644
--- a/apps/files_sharing/lib/External/Storage.php
+++ b/apps/files_sharing/lib/External/Storage.php
@@ -1,4 +1,7 @@
<?php
+
+declare(strict_types=1);
+
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -8,6 +11,7 @@
* @author Daniel Kesselberg <mail@danielkesselberg.de>
* @author Joas Schilling <coding@schilljs.com>
* @author Lukas Reschke <lukas@statuscode.ch>
+ * @author Maxence Lange <maxence@artificial-owl.com>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
* @author Roeland Jago Douma <roeland@famdouma.nl>
@@ -36,8 +40,8 @@ use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\RequestException;
use OC\Files\Storage\DAV;
use OC\ForbiddenException;
-use OCA\Files_Sharing\ISharedStorage;
use OCA\Files_Sharing\External\Manager as ExternalShareManager;
+use OCA\Files_Sharing\ISharedStorage;
use OCP\AppFramework\Http;
use OCP\Constants;
use OCP\Federation\ICloudId;
@@ -46,25 +50,25 @@ use OCP\Files\Storage\IDisableEncryptionStorage;
use OCP\Files\Storage\IReliableEtagStorage;
use OCP\Files\StorageInvalidException;
use OCP\Files\StorageNotAvailableException;
-use OCP\Http\Client\LocalServerException;
use OCP\Http\Client\IClientService;
+use OCP\Http\Client\LocalServerException;
+use OCP\ICacheFactory;
+use OCP\IConfig;
+use OCP\OCM\Exceptions\OCMArgumentException;
+use OCP\OCM\Exceptions\OCMProviderException;
+use OCP\OCM\IOCMDiscoveryService;
+use OCP\Server;
+use Psr\Log\LoggerInterface;
class Storage extends DAV implements ISharedStorage, IDisableEncryptionStorage, IReliableEtagStorage {
- /** @var ICloudId */
- private $cloudId;
- /** @var string */
- private $mountPoint;
- /** @var string */
- private $token;
- /** @var \OCP\ICacheFactory */
- private $memcacheFactory;
- /** @var \OCP\Http\Client\IClientService */
- private $httpClient;
- /** @var bool */
- private $updateChecked = false;
-
- /** @var ExternalShareManager */
- private $manager;
+ private ICloudId $cloudId;
+ private string $mountPoint;
+ private string $token;
+ private ICacheFactory $memcacheFactory;
+ private IClientService $httpClient;
+ private bool $updateChecked = false;
+ private ExternalShareManager $manager;
+ private IConfig $config;
/**
* @param array{HttpClientService: IClientService, manager: ExternalShareManager, cloudId: ICloudId, mountpoint: string, token: string, password: ?string}|array $options
@@ -72,32 +76,46 @@ class Storage extends DAV implements ISharedStorage, IDisableEncryptionStorage,
public function __construct($options) {
$this->memcacheFactory = \OC::$server->getMemCacheFactory();
$this->httpClient = $options['HttpClientService'];
-
$this->manager = $options['manager'];
$this->cloudId = $options['cloudId'];
- $discoveryService = \OC::$server->query(\OCP\OCS\IDiscoveryService::class);
+ $this->logger = Server::get(LoggerInterface::class);
+ $discoveryService = Server::get(IOCMDiscoveryService::class);
+ $this->config = Server::get(IConfig::class);
- [$protocol, $remote] = explode('://', $this->cloudId->getRemote());
- if (str_contains($remote, '/')) {
- [$host, $root] = explode('/', $remote, 2);
- } else {
- $host = $remote;
- $root = '';
+ // use default path to webdav if not found on discovery
+ try {
+ $ocmProvider = $discoveryService->discover($this->cloudId->getRemote());
+ $webDavEndpoint = $ocmProvider->extractProtocolEntry('file', 'webdav');
+ $remote = $ocmProvider->getEndPoint();
+ } catch (OCMProviderException|OCMArgumentException $e) {
+ $this->logger->notice('exception while retrieving webdav endpoint', ['exception' => $e]);
+ $webDavEndpoint = '/public.php/webdav';
+ $remote = $this->cloudId->getRemote();
+ }
+
+ $host = parse_url($remote, PHP_URL_HOST);
+ $port = parse_url($remote, PHP_URL_PORT);
+ $host .= (null === $port) ? '' : ':' . $port; // we add port if available
+
+ // in case remote NC is on a sub folder and using deprecated ocm provider
+ $tmpPath = rtrim(parse_url($this->cloudId->getRemote(), PHP_URL_PATH) ?? '', '/');
+ if (!str_starts_with($webDavEndpoint, $tmpPath)) {
+ $webDavEndpoint = $tmpPath . $webDavEndpoint;
}
- $secure = $protocol === 'https';
- $federatedSharingEndpoints = $discoveryService->discover($this->cloudId->getRemote(), 'FEDERATED_SHARING');
- $webDavEndpoint = isset($federatedSharingEndpoints['webdav']) ? $federatedSharingEndpoints['webdav'] : '/public.php/webdav';
- $root = rtrim($root, '/') . $webDavEndpoint;
+
$this->mountPoint = $options['mountpoint'];
$this->token = $options['token'];
- parent::__construct([
- 'secure' => $secure,
- 'host' => $host,
- 'root' => $root,
- 'user' => $options['token'],
- 'password' => (string)$options['password']
- ]);
+ parent::__construct(
+ [
+ 'secure' => ((parse_url($remote, PHP_URL_SCHEME) ?? 'https') === 'https'),
+ 'host' => $host,
+ 'root' => $webDavEndpoint,
+ 'user' => $options['token'],
+ 'authType' => \Sabre\DAV\Client::AUTH_BASIC,
+ 'password' => (string)$options['password']
+ ]
+ );
}
public function getWatcher($path = '', $storage = null) {
@@ -255,9 +273,9 @@ class Storage extends DAV implements ISharedStorage, IDisableEncryptionStorage,
*/
protected function testRemote(): bool {
try {
- return $this->testRemoteUrl($this->getRemote() . '/ocs-provider/index.php')
- || $this->testRemoteUrl($this->getRemote() . '/ocs-provider/')
- || $this->testRemoteUrl($this->getRemote() . '/status.php');
+ return $this->testRemoteUrl($this->getRemote() . '/ocm-provider/index.php')
+ || $this->testRemoteUrl($this->getRemote() . '/ocm-provider/')
+ || $this->testRemoteUrl($this->getRemote() . '/status.php');
} catch (\Exception $e) {
return false;
}
@@ -275,6 +293,7 @@ class Storage extends DAV implements ISharedStorage, IDisableEncryptionStorage,
$result = $client->get($url, [
'timeout' => 10,
'connect_timeout' => 10,
+ 'verify' => !$this->config->getSystemValueBool('sharing.federation.allowSelfSignedCertificates', false),
])->getBody();
$data = json_decode($result);
$returnValue = (is_object($data) && !empty($data->version));
diff --git a/apps/files_sharing/lib/ISharedMountPoint.php b/apps/files_sharing/lib/ISharedMountPoint.php
new file mode 100644
index 00000000000..f3947599c29
--- /dev/null
+++ b/apps/files_sharing/lib/ISharedMountPoint.php
@@ -0,0 +1,28 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2023 Robin Appelman <robin@icewind.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Files_Sharing;
+
+interface ISharedMountPoint {
+
+}
diff --git a/apps/files_sharing/lib/Listener/LoadAdditionalListener.php b/apps/files_sharing/lib/Listener/LoadAdditionalListener.php
index 583cd575793..514c6ba0aa3 100644
--- a/apps/files_sharing/lib/Listener/LoadAdditionalListener.php
+++ b/apps/files_sharing/lib/Listener/LoadAdditionalListener.php
@@ -25,13 +25,14 @@ declare(strict_types=1);
*/
namespace OCA\Files_Sharing\Listener;
-use OCA\Files_Sharing\AppInfo\Application;
use OCA\Files\Event\LoadAdditionalScriptsEvent;
+use OCA\Files_Sharing\AppInfo\Application;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\Share\IManager;
use OCP\Util;
+/** @template-implements IEventListener<LoadAdditionalScriptsEvent> */
class LoadAdditionalListener implements IEventListener {
public function handle(Event $event): void {
if (!($event instanceof LoadAdditionalScriptsEvent)) {
@@ -44,7 +45,7 @@ class LoadAdditionalListener implements IEventListener {
$shareManager = \OC::$server->get(IManager::class);
if ($shareManager->shareApiEnabled() && class_exists('\OCA\Files\App')) {
- Util::addScript(Application::APP_ID, 'files_sharing', 'files');
+ Util::addInitScript(Application::APP_ID, 'init');
}
}
}
diff --git a/apps/files_sharing/lib/Listener/LoadSidebarListener.php b/apps/files_sharing/lib/Listener/LoadSidebarListener.php
index cb5ebf8a792..f82f60a170d 100644
--- a/apps/files_sharing/lib/Listener/LoadSidebarListener.php
+++ b/apps/files_sharing/lib/Listener/LoadSidebarListener.php
@@ -23,15 +23,25 @@ declare(strict_types=1);
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
+
namespace OCA\Files_Sharing\Listener;
-use OCA\Files_Sharing\AppInfo\Application;
use OCA\Files\Event\LoadSidebar;
+use OCA\Files_Sharing\AppInfo\Application;
+use OCP\AppFramework\Services\IInitialState;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
+use OCP\Share\IManager;
use OCP\Util;
+/**
+ * @template-implements IEventListener<LoadSidebar>
+ */
class LoadSidebarListener implements IEventListener {
+
+ public function __construct(private IInitialState $initialState, private IManager $shareManager) {
+ }
+
public function handle(Event $event): void {
if (!($event instanceof LoadSidebar)) {
return;
diff --git a/apps/files_sharing/lib/Listener/ShareInteractionListener.php b/apps/files_sharing/lib/Listener/ShareInteractionListener.php
index 9eb69de7e83..f97da311374 100644
--- a/apps/files_sharing/lib/Listener/ShareInteractionListener.php
+++ b/apps/files_sharing/lib/Listener/ShareInteractionListener.php
@@ -36,6 +36,7 @@ use OCP\Share\IShare;
use Psr\Log\LoggerInterface;
use function in_array;
+/** @template-implements IEventListener<ShareCreatedEvent> */
class ShareInteractionListener implements IEventListener {
private const SUPPORTED_SHARE_TYPES = [
IShare::TYPE_USER,
diff --git a/apps/files_sharing/lib/Listener/UserAddedToGroupListener.php b/apps/files_sharing/lib/Listener/UserAddedToGroupListener.php
index 1f3898b3dcb..e3273e48516 100644
--- a/apps/files_sharing/lib/Listener/UserAddedToGroupListener.php
+++ b/apps/files_sharing/lib/Listener/UserAddedToGroupListener.php
@@ -33,6 +33,7 @@ use OCP\IConfig;
use OCP\Share\IManager;
use OCP\Share\IShare;
+/** @template-implements IEventListener<UserAddedEvent> */
class UserAddedToGroupListener implements IEventListener {
/** @var IManager */
diff --git a/apps/files_sharing/lib/Listener/UserShareAcceptanceListener.php b/apps/files_sharing/lib/Listener/UserShareAcceptanceListener.php
index 160a806f8ac..8de9f0ae267 100644
--- a/apps/files_sharing/lib/Listener/UserShareAcceptanceListener.php
+++ b/apps/files_sharing/lib/Listener/UserShareAcceptanceListener.php
@@ -36,6 +36,7 @@ use OCP\Share\Events\ShareCreatedEvent;
use OCP\Share\IManager;
use OCP\Share\IShare;
+/** @template-implements IEventListener<ShareCreatedEvent> */
class UserShareAcceptanceListener implements IEventListener {
/** @var IConfig */
diff --git a/apps/files_sharing/lib/Middleware/OCSShareAPIMiddleware.php b/apps/files_sharing/lib/Middleware/OCSShareAPIMiddleware.php
index 1c961ffed34..aba6124f415 100644
--- a/apps/files_sharing/lib/Middleware/OCSShareAPIMiddleware.php
+++ b/apps/files_sharing/lib/Middleware/OCSShareAPIMiddleware.php
@@ -39,7 +39,7 @@ class OCSShareAPIMiddleware extends Middleware {
private $l;
public function __construct(IManager $shareManager,
- IL10N $l) {
+ IL10N $l) {
$this->shareManager = $shareManager;
$this->l = $l;
}
diff --git a/apps/files_sharing/lib/Middleware/SharingCheckMiddleware.php b/apps/files_sharing/lib/Middleware/SharingCheckMiddleware.php
index b9bab169d1d..005fc75c849 100644
--- a/apps/files_sharing/lib/Middleware/SharingCheckMiddleware.php
+++ b/apps/files_sharing/lib/Middleware/SharingCheckMiddleware.php
@@ -64,12 +64,12 @@ class SharingCheckMiddleware extends Middleware {
protected $request;
public function __construct(string $appName,
- IConfig $config,
- IAppManager $appManager,
- IControllerMethodReflector $reflector,
- IManager $shareManager,
- IRequest $request
- ) {
+ IConfig $config,
+ IAppManager $appManager,
+ IControllerMethodReflector $reflector,
+ IManager $shareManager,
+ IRequest $request
+ ) {
$this->appName = $appName;
$this->config = $config;
$this->appManager = $appManager;
diff --git a/apps/files_sharing/lib/Migration/OwncloudGuestShareType.php b/apps/files_sharing/lib/Migration/OwncloudGuestShareType.php
index d1ba645f93d..57b441172ee 100644
--- a/apps/files_sharing/lib/Migration/OwncloudGuestShareType.php
+++ b/apps/files_sharing/lib/Migration/OwncloudGuestShareType.php
@@ -68,7 +68,7 @@ class OwncloudGuestShareType implements IRepairStep {
$query = $this->connection->getQueryBuilder();
$query->update('share')
- ->set('share_type', $query->createNamedParameter(IShare::TYPE_GUEST))
+ ->set('share_type', $query->createNamedParameter(IShare::TYPE_GUEST))
->where($query->expr()->eq('share_type', $query->createNamedParameter(IShare::TYPE_EMAIL)));
$query->execute();
}
diff --git a/apps/files_sharing/lib/Migration/Version11300Date20201120141438.php b/apps/files_sharing/lib/Migration/Version11300Date20201120141438.php
index 50d0cd9e066..ec514c9154f 100644
--- a/apps/files_sharing/lib/Migration/Version11300Date20201120141438.php
+++ b/apps/files_sharing/lib/Migration/Version11300Date20201120141438.php
@@ -29,8 +29,8 @@ namespace OCA\Files_Sharing\Migration;
use Closure;
use Doctrine\DBAL\Types\Type;
-use OCP\DB\Types;
use OCP\DB\ISchemaWrapper;
+use OCP\DB\Types;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
diff --git a/apps/files_sharing/lib/Migration/Version21000Date20201223143245.php b/apps/files_sharing/lib/Migration/Version21000Date20201223143245.php
index ff7722eaa58..c393295a367 100644
--- a/apps/files_sharing/lib/Migration/Version21000Date20201223143245.php
+++ b/apps/files_sharing/lib/Migration/Version21000Date20201223143245.php
@@ -27,8 +27,8 @@ declare(strict_types=1);
namespace OCA\Files_Sharing\Migration;
use Closure;
-use OCP\DB\Types;
use OCP\DB\ISchemaWrapper;
+use OCP\DB\Types;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
diff --git a/apps/files_sharing/lib/Migration/Version24000Date20220208195521.php b/apps/files_sharing/lib/Migration/Version24000Date20220208195521.php
index d5f938dde6d..8b95e32eb4f 100644
--- a/apps/files_sharing/lib/Migration/Version24000Date20220208195521.php
+++ b/apps/files_sharing/lib/Migration/Version24000Date20220208195521.php
@@ -26,8 +26,8 @@ declare(strict_types=1);
namespace OCA\Files_Sharing\Migration;
use Closure;
-use OCP\DB\Types;
use OCP\DB\ISchemaWrapper;
+use OCP\DB\Types;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
diff --git a/apps/files_sharing/lib/MountProvider.php b/apps/files_sharing/lib/MountProvider.php
index d4cc13842a3..dce67b7ef98 100644
--- a/apps/files_sharing/lib/MountProvider.php
+++ b/apps/files_sharing/lib/MountProvider.php
@@ -28,9 +28,9 @@
*/
namespace OCA\Files_Sharing;
-use OCP\Cache\CappedMemoryCache;
use OC\Files\View;
use OCA\Files_Sharing\Event\ShareMountedEvent;
+use OCP\Cache\CappedMemoryCache;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Config\IMountProvider;
use OCP\Files\Storage\IStorageFactory;
diff --git a/apps/files_sharing/lib/Notification/Notifier.php b/apps/files_sharing/lib/Notification/Notifier.php
index d339c484dd7..20ad9c7e755 100644
--- a/apps/files_sharing/lib/Notification/Notifier.php
+++ b/apps/files_sharing/lib/Notification/Notifier.php
@@ -61,11 +61,11 @@ class Notifier implements INotifier {
protected $url;
public function __construct(IFactory $l10nFactory,
- IManager $shareManager,
- IRootFolder $rootFolder,
- IGroupManager $groupManager,
- IUserManager $userManager,
- IURLGenerator $url) {
+ IManager $shareManager,
+ IRootFolder $rootFolder,
+ IGroupManager $groupManager,
+ IUserManager $userManager,
+ IURLGenerator $url) {
$this->l10nFactory = $l10nFactory;
$this->shareManager = $shareManager;
$this->rootFolder = $rootFolder;
diff --git a/apps/files_sharing/lib/OrphanHelper.php b/apps/files_sharing/lib/OrphanHelper.php
index 6d15680f882..e4fd062db3b 100644
--- a/apps/files_sharing/lib/OrphanHelper.php
+++ b/apps/files_sharing/lib/OrphanHelper.php
@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace OCA\Files_Sharing;
+use OC\User\NoUserException;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\Files\IRootFolder;
use OCP\IDBConnection;
@@ -40,7 +41,11 @@ class OrphanHelper {
}
public function isShareValid(string $owner, int $fileId): bool {
- $userFolder = $this->rootFolder->getUserFolder($owner);
+ try {
+ $userFolder = $this->rootFolder->getUserFolder($owner);
+ } catch (NoUserException $e) {
+ return false;
+ }
$nodes = $userFolder->getById($fileId);
return count($nodes) > 0;
}
diff --git a/apps/files_sharing/lib/ResponseDefinitions.php b/apps/files_sharing/lib/ResponseDefinitions.php
index e2e5d6d7ba3..313cf82bd51 100644
--- a/apps/files_sharing/lib/ResponseDefinitions.php
+++ b/apps/files_sharing/lib/ResponseDefinitions.php
@@ -1,4 +1,5 @@
<?php
+
declare(strict_types=1);
/**
@@ -26,7 +27,7 @@ declare(strict_types=1);
namespace OCA\Files_Sharing;
/**
- * @psalm-type FilesSharingShare = array{
+ * @psalm-type Files_SharingShare = array{
* attributes: ?string,
* can_delete: bool,
* can_edit: bool,
@@ -49,18 +50,18 @@ namespace OCA\Files_Sharing;
* mimetype: string,
* note: string,
* parent: null,
- * password?: string,
+ * password?: null|string,
* password_expiration_time?: ?string,
* path: ?string,
* permissions: int,
* send_password_by_talk?: bool,
* share_type: int,
- * share_with?: string,
+ * share_with?: null|string,
* share_with_avatar?: string,
* share_with_displayname?: string,
* share_with_displayname_unique?: ?string,
* share_with_link?: string,
- * status?: array{clearAt?: int|null, icon?: ?string, message?: ?string, status?: string},
+ * status?: array{clearAt: int|null, icon: ?string, message: ?string, status: string},
* stime: int,
* storage: int,
* storage_id: string,
@@ -70,7 +71,7 @@ namespace OCA\Files_Sharing;
* url?: string,
* }
*
- * @psalm-type FilesSharingDeletedShare = array{
+ * @psalm-type Files_SharingDeletedShare = array{
* id: string,
* share_type: int,
* uid_owner: string,
@@ -93,7 +94,7 @@ namespace OCA\Files_Sharing;
* share_with_link: string|null,
* }
*
- * @psalm-type FilesSharingRemoteShare = array{
+ * @psalm-type Files_SharingRemoteShare = array{
* accepted: bool,
* file_id: int|null,
* id: int,
@@ -112,17 +113,17 @@ namespace OCA\Files_Sharing;
* user: string,
* }
*
- * @psalm-type FilesSharingSharee = array{
+ * @psalm-type Files_SharingSharee = array{
* count: int|null,
* label: string,
* }
*
- * @psalm-type FilesSharingShareeValue = array{
+ * @psalm-type Files_SharingShareeValue = array{
* shareType: int,
* shareWith: string,
* }
*
- * @psalm-type FilesSharingShareeUser = FilesSharingSharee&array{
+ * @psalm-type Files_SharingShareeUser = Files_SharingSharee&array{
* subline: string,
* icon: string,
* shareWithDisplayNameUnique: string,
@@ -132,101 +133,101 @@ namespace OCA\Files_Sharing;
* icon: string,
* clearAt: int|null,
* },
- * value: FilesSharingShareeValue,
+ * value: Files_SharingShareeValue,
* }
*
- * @psalm-type FilesSharingShareeRemoteGroup = FilesSharingSharee&array{
+ * @psalm-type Files_SharingShareeRemoteGroup = Files_SharingSharee&array{
* guid: string,
* name: string,
- * value: FilesSharingShareeValue&array{
+ * value: Files_SharingShareeValue&array{
* server: string,
* }
* }
*
- * @psalm-type FilesSharingLookup = array{
+ * @psalm-type Files_SharingLookup = array{
* value: string,
* verified: int,
* }
*
- * @psalm-type FilesSharingShareeLookup = FilesSharingSharee&array{
+ * @psalm-type Files_SharingShareeLookup = Files_SharingSharee&array{
* extra: array{
* federationId: string,
- * name: FilesSharingLookup|null,
- * email: FilesSharingLookup|null,
- * address: FilesSharingLookup|null,
- * website: FilesSharingLookup|null,
- * twitter: FilesSharingLookup|null,
- * phone: FilesSharingLookup|null,
- * twitter_signature: FilesSharingLookup|null,
- * website_signature: FilesSharingLookup|null,
- * userid: FilesSharingLookup|null,
+ * name: Files_SharingLookup|null,
+ * email: Files_SharingLookup|null,
+ * address: Files_SharingLookup|null,
+ * website: Files_SharingLookup|null,
+ * twitter: Files_SharingLookup|null,
+ * phone: Files_SharingLookup|null,
+ * twitter_signature: Files_SharingLookup|null,
+ * website_signature: Files_SharingLookup|null,
+ * userid: Files_SharingLookup|null,
* },
- * value: FilesSharingShareeValue&array{
+ * value: Files_SharingShareeValue&array{
* globalScale: bool,
* }
* }
*
- * @psalm-type FilesSharingShareeEmail = FilesSharingSharee&array{
+ * @psalm-type Files_SharingShareeEmail = Files_SharingSharee&array{
* uuid: string,
* name: string,
* type: string,
* shareWithDisplayNameUnique: string,
- * value: FilesSharingShareeValue,
+ * value: Files_SharingShareeValue,
* }
*
- * @psalm-type FilesSharingShareeRemote = FilesSharingSharee&array{
+ * @psalm-type Files_SharingShareeRemote = Files_SharingSharee&array{
* uuid: string,
* name: string,
* type: string,
- * value: FilesSharingShareeValue&array{
+ * value: Files_SharingShareeValue&array{
* server: string,
* }
* }
*
- * @psalm-type FilesSharingShareeCircle = FilesSharingSharee&array{
+ * @psalm-type Files_SharingShareeCircle = Files_SharingSharee&array{
* shareWithDescription: string,
- * value: FilesSharingShareeValue&array{
+ * value: Files_SharingShareeValue&array{
* circle: string,
* }
* }
*
- * @psalm-type FilesSharingShareesSearchResult = array{
+ * @psalm-type Files_SharingShareesSearchResult = array{
* exact: array{
- * circles: FilesSharingShareeCircle[],
- * emails: FilesSharingShareeEmail[],
- * groups: FilesSharingSharee[],
- * remote_groups: FilesSharingShareeRemoteGroup[],
- * remotes: FilesSharingShareeRemote[],
- * rooms: FilesSharingSharee[],
- * users: FilesSharingShareeUser[],
+ * circles: Files_SharingShareeCircle[],
+ * emails: Files_SharingShareeEmail[],
+ * groups: Files_SharingSharee[],
+ * remote_groups: Files_SharingShareeRemoteGroup[],
+ * remotes: Files_SharingShareeRemote[],
+ * rooms: Files_SharingSharee[],
+ * users: Files_SharingShareeUser[],
* },
- * circles: FilesSharingShareeCircle[],
- * emails: FilesSharingShareeEmail[],
- * groups: FilesSharingSharee[],
- * lookup: FilesSharingShareeLookup[],
- * remote_groups: FilesSharingShareeRemoteGroup[],
- * remotes: FilesSharingShareeRemote[],
- * rooms: FilesSharingSharee[],
- * users: FilesSharingShareeUser[],
+ * circles: Files_SharingShareeCircle[],
+ * emails: Files_SharingShareeEmail[],
+ * groups: Files_SharingSharee[],
+ * lookup: Files_SharingShareeLookup[],
+ * remote_groups: Files_SharingShareeRemoteGroup[],
+ * remotes: Files_SharingShareeRemote[],
+ * rooms: Files_SharingSharee[],
+ * users: Files_SharingShareeUser[],
* lookupEnabled: bool,
* }
*
- * @psalm-type FilesSharingShareesRecommendedResult = array{
+ * @psalm-type Files_SharingShareesRecommendedResult = array{
* exact: array{
- * emails: FilesSharingShareeEmail[],
- * groups: FilesSharingSharee[],
- * remote_groups: FilesSharingShareeRemoteGroup[],
- * remotes: FilesSharingShareeRemote[],
- * users: FilesSharingShareeUser[],
+ * emails: Files_SharingShareeEmail[],
+ * groups: Files_SharingSharee[],
+ * remote_groups: Files_SharingShareeRemoteGroup[],
+ * remotes: Files_SharingShareeRemote[],
+ * users: Files_SharingShareeUser[],
* },
- * emails: FilesSharingShareeEmail[],
- * groups: FilesSharingSharee[],
- * remote_groups: FilesSharingShareeRemoteGroup[],
- * remotes: FilesSharingShareeRemote[],
- * users: FilesSharingShareeUser[],
+ * emails: Files_SharingShareeEmail[],
+ * groups: Files_SharingSharee[],
+ * remote_groups: Files_SharingShareeRemoteGroup[],
+ * remotes: Files_SharingShareeRemote[],
+ * users: Files_SharingShareeUser[],
* }
*
- * @psalm-type FilesSharingShareInfo = array{
+ * @psalm-type Files_SharingShareInfo = array{
* id: int,
* parentId: int,
* mtime: int,
diff --git a/apps/files_sharing/lib/ShareBackend/File.php b/apps/files_sharing/lib/ShareBackend/File.php
index c84cbd66c67..23096d64156 100644
--- a/apps/files_sharing/lib/ShareBackend/File.php
+++ b/apps/files_sharing/lib/ShareBackend/File.php
@@ -35,6 +35,7 @@ namespace OCA\Files_Sharing\ShareBackend;
use OCA\FederatedFileSharing\FederatedShareProvider;
use OCP\Share\IShare;
+use Psr\Log\LoggerInterface;
class File implements \OCP\Share_Backend_File_Dependent {
public const FORMAT_SHARED_STORAGE = 0;
@@ -233,7 +234,7 @@ class File implements \OCP\Share_Backend_File_Dependent {
if (isset($fileOwner)) {
$source['fileOwner'] = $fileOwner;
} else {
- \OC::$server->getLogger()->error('No owner found for reshare', ['app' => 'files_sharing']);
+ \OCP\Server::get(LoggerInterface::class)->error('No owner found for reshare', ['app' => 'files_sharing']);
}
return $source;
diff --git a/apps/files_sharing/lib/SharedMount.php b/apps/files_sharing/lib/SharedMount.php
index 6cde9f82bec..66a3b619df0 100644
--- a/apps/files_sharing/lib/SharedMount.php
+++ b/apps/files_sharing/lib/SharedMount.php
@@ -29,22 +29,23 @@
namespace OCA\Files_Sharing;
-use OCP\Cache\CappedMemoryCache;
use OC\Files\Filesystem;
use OC\Files\Mount\MountPoint;
use OC\Files\Mount\MoveableMount;
use OC\Files\View;
+use OCP\Cache\CappedMemoryCache;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Events\InvalidateMountCacheEvent;
use OCP\Files\Storage\IStorageFactory;
use OCP\ICache;
use OCP\IUser;
use OCP\Share\Events\VerifyMountPointEvent;
+use Psr\Log\LoggerInterface;
/**
* Shared mount points can be moved by the user
*/
-class SharedMount extends MountPoint implements MoveableMount {
+class SharedMount extends MountPoint implements MoveableMount, ISharedMountPoint {
/**
* @var \OCA\Files_Sharing\SharedStorage $storage
*/
@@ -198,7 +199,7 @@ class SharedMount extends MountPoint implements MoveableMount {
// it is not a file relative to data/user/files
if (count($split) < 3 || $split[1] !== 'files') {
- \OC::$server->getLogger()->error('Can not strip userid and "files/" from path: ' . $path, ['app' => 'files_sharing']);
+ \OCP\Server::get(LoggerInterface::class)->error('Can not strip userid and "files/" from path: ' . $path, ['app' => 'files_sharing']);
throw new \OCA\Files_Sharing\Exceptions\BrokenPath('Path does not start with /user/files', 10);
}
@@ -226,7 +227,13 @@ class SharedMount extends MountPoint implements MoveableMount {
$this->setMountPoint($target);
$this->storage->setMountPoint($relTargetPath);
} catch (\Exception $e) {
- \OC::$server->getLogger()->logException($e, ['app' => 'files_sharing', 'message' => 'Could not rename mount point for shared folder "' . $this->getMountPoint() . '" to "' . $target . '"']);
+ \OCP\Server::get(LoggerInterface::class)->error(
+ 'Could not rename mount point for shared folder "' . $this->getMountPoint() . '" to "' . $target . '"',
+ [
+ 'app' => 'files_sharing',
+ 'exception' => $e,
+ ]
+ );
}
return $result;
diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php
index b2d06b71437..6b605a6eddb 100644
--- a/apps/files_sharing/lib/SharedStorage.php
+++ b/apps/files_sharing/lib/SharedStorage.php
@@ -32,24 +32,24 @@
*/
namespace OCA\Files_Sharing;
+use OC\Files\Cache\CacheDependencies;
use OC\Files\Cache\FailedCache;
use OC\Files\Cache\NullWatcher;
use OC\Files\Cache\Watcher;
use OC\Files\ObjectStore\HomeObjectStoreStorage;
use OC\Files\Storage\Common;
-use OC\Files\Storage\Home;
-use OC\User\DisplayNameCache;
-use OCA\Files_External\Config\ConfigAdapter;
-use OCP\Files\Config\IUserMountCache;
-use OCP\Files\Folder;
-use OCP\Files\IHomeStorage;
-use OCP\Files\Node;
use OC\Files\Storage\FailedStorage;
+use OC\Files\Storage\Home;
use OC\Files\Storage\Wrapper\PermissionsMask;
use OC\User\NoUserException;
+use OCA\Files_External\Config\ConfigAdapter;
use OCP\Constants;
use OCP\Files\Cache\ICacheEntry;
+use OCP\Files\Config\IUserMountCache;
+use OCP\Files\Folder;
+use OCP\Files\IHomeStorage;
use OCP\Files\IRootFolder;
+use OCP\Files\Node;
use OCP\Files\NotFoundException;
use OCP\Files\Storage\IDisableEncryptionStorage;
use OCP\Files\Storage\IStorage;
@@ -411,10 +411,10 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements ISharedSto
return new FailedCache();
}
- $this->cache = new \OCA\Files_Sharing\Cache(
+ $this->cache = new Cache(
$storage,
$sourceRoot,
- \OC::$server->get(DisplayNameCache::class),
+ \OC::$server->get(CacheDependencies::class),
$this->getShare()
);
return $this->cache;
diff --git a/apps/files_sharing/lib/Updater.php b/apps/files_sharing/lib/Updater.php
index 59e06e60299..95a5c9d9166 100644
--- a/apps/files_sharing/lib/Updater.php
+++ b/apps/files_sharing/lib/Updater.php
@@ -28,8 +28,8 @@ namespace OCA\Files_Sharing;
use OC\Files\Mount\MountPoint;
use OCP\Constants;
-use OCP\Share\IShare;
use OCP\Files\Folder;
+use OCP\Share\IShare;
class Updater {