diff options
author | Robin Appelman <robin@icewind.nl> | 2023-08-14 15:50:05 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2023-08-14 18:17:27 +0200 |
commit | a031bc4788229b7943a13202998e895d08161490 (patch) | |
tree | ae541c4c09c7cbcd4391013951424ff3a9435523 /lib/private/Files/SetupManager.php | |
parent | dfbc0d8572395c459aa80df5e503b8688e2b7f6f (diff) | |
download | nextcloud-server-a031bc4788229b7943a13202998e895d08161490.tar.gz nextcloud-server-a031bc4788229b7943a13202998e895d08161490.zip |
more share permission logic to storage wrapper
this way we only have to determine the share permissions once
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/Files/SetupManager.php')
-rw-r--r-- | lib/private/Files/SetupManager.php | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/private/Files/SetupManager.php b/lib/private/Files/SetupManager.php index 2198c8c60b7..b1d609a9225 100644 --- a/lib/private/Files/SetupManager.php +++ b/lib/private/Files/SetupManager.php @@ -34,9 +34,11 @@ use OC\Files\Storage\Wrapper\Encoding; use OC\Files\Storage\Wrapper\PermissionsMask; use OC\Files\Storage\Wrapper\Quota; use OC\Lockdown\Filesystem\NullStorage; +use OC\Share\Share; use OC_App; use OC_Hook; use OC_Util; +use OCA\Files_Sharing\ISharedStorage; use OCP\Constants; use OCP\Diagnostics\IEventLogger; use OCP\EventDispatcher\IEventDispatcher; @@ -60,6 +62,7 @@ use OCP\IUserManager; use OCP\IUserSession; use OCP\Lockdown\ILockdownManager; use OCP\Share\Events\ShareCreatedEvent; +use OCP\Share\IManager; use Psr\Log\LoggerInterface; class SetupManager { @@ -139,8 +142,17 @@ class SetupManager { return $storage; }); - Filesystem::addStorageWrapper('enable_sharing', function ($mountPoint, IStorage $storage, IMountPoint $mount) { - if (!$mount->getOption('enable_sharing', true)) { + Filesystem::addStorageWrapper('sharing_mask', function ($mountPoint, IStorage $storage, IMountPoint $mount) { + $reSharingEnabled = Share::isResharingAllowed(); + $sharingEnabledForMount = $mount->getOption('enable_sharing', true); + /** @var IUserSession $userSession */ + $userSession = \OC::$server->get(IUserSession::class); + $user = $userSession->getUser(); + /** @var IManager $shareManager */ + $shareManager = \OC::$server->get(IManager::class); + $sharingEnabledForUser = $user ? !$shareManager->sharingDisabledForUser($user->getUID()) : true; + $isShared = $storage->instanceOfStorage(ISharedStorage::class); + if (!$sharingEnabledForMount || !$sharingEnabledForUser || (!$reSharingEnabled && $isShared)) { return new PermissionsMask([ 'storage' => $storage, 'mask' => Constants::PERMISSION_ALL - Constants::PERMISSION_SHARE, |