diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php
index c1edd409c431b..030e751491e02 100644
--- a/apps/files_sharing/lib/Controller/ShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareAPIController.php
@@ -1510,8 +1510,29 @@ protected function canAccessShare(\OCP\Share\IShare $share, bool $checkGroups =
}
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 8ce1af0776e41..2fb24aa2a5348 100644
--- a/build/psalm-baseline.xml
+++ b/build/psalm-baseline.xml
@@ -886,6 +886,7 @@
+
getRoomShareHelper()]]>