diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index 8e1dc4ed949a1..41d073b134d14 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -1552,8 +1552,29 @@ protected function canAccessShare(IShare $share, bool $checkGroups = true): bool } if ($share->getShareType() === IShare::TYPE_CIRCLE) { - // TODO: have a sanity check like above? - return true; + if ( + Server::get(IAppManager::class)->isEnabledForUser('circles') + && class_exists('\OCA\Circles\Api\v1\Circles') + ) { + $hasCircleId = (str_ends_with($share->getSharedWith(), ']')); + $shareWithStart = ($hasCircleId ? strrpos($share->getSharedWith(), '[') + 1 : 0); + $shareWithLength = ($hasCircleId ? -1 : strpos($share->getSharedWith(), ' ')); + if ($shareWithLength === false) { + $sharedWith = substr($share->getSharedWith(), $shareWithStart); + } else { + $sharedWith = substr($share->getSharedWith(), $shareWithStart, $shareWithLength); + } + try { + $member = Circles::getMember($sharedWith, $this->userId, 1); + if ($member->getLevel() >= 1) { + return true; + } + return false; + } catch (\Exception $e) { + return false; + } + } + return false; } if ($share->getShareType() === IShare::TYPE_ROOM) { diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml index 7659a6698f29e..530548f1896e6 100644 --- a/build/psalm-baseline.xml +++ b/build/psalm-baseline.xml @@ -1528,6 +1528,7 @@ + getRoomShareHelper()]]>