diff --git a/lib/Db/ShareWrapperRequest.php b/lib/Db/ShareWrapperRequest.php index 70d75450d..12e9f85d0 100644 --- a/lib/Db/ShareWrapperRequest.php +++ b/lib/Db/ShareWrapperRequest.php @@ -183,18 +183,16 @@ public function getSharesToCircle( /** - * @param string $circleId - * @param FederatedUser|null $shareRecipient - * @param FederatedUser|null $shareInitiator - * @param bool $completeDetails - * * @return ShareWrapper[] * @throws RequestBuilderException */ - public function getSharesToCircles(array $circleIds): array { + public function getSharesToCircles(array $circleIds, ?string $fileId = null): array { $qb = $this->getShareSelectSql(); $qb->limitNull('parent', false); - $qb->expr()->in('share_with', $qb->createNamedParameter($circleIds, IQueryBuilder::PARAM_STR_ARRAY)); + $qb->andWhere($qb->expr()->in('share_with', $qb->createNamedParameter($circleIds, IQueryBuilder::PARAM_STR_ARRAY))); + if ($fileId !== null) { + $qb->limitToFileSource((int)$fileId); + } return $this->getItemsFromRequest($qb); } diff --git a/lib/FileSharingTeamResourceProvider.php b/lib/FileSharingTeamResourceProvider.php index 3066b4967..504f27466 100644 --- a/lib/FileSharingTeamResourceProvider.php +++ b/lib/FileSharingTeamResourceProvider.php @@ -20,7 +20,7 @@ class FileSharingTeamResourceProvider implements ITeamResourceProvider { public function __construct( private IL10N $l10n, private ?CirclesManager $circlesManager, - private ShareWrapperService $shareByCircleProvider, + private ShareWrapperService $shareWrapperService, private IURLGenerator $urlGenerator, ) { } @@ -42,24 +42,20 @@ public function getSharedWith(string $teamId): array { return []; } - $shares = $this->shareByCircleProvider->getSharesToCircle($teamId); + $shares = $this->shareWrapperService->getSharesToCircle($teamId); return $this->convertWrappedShareToResource($shares); } /** * @return array */ - public function getSharedWithList(array $teams): array { - $data = $shares = []; - foreach ($this->shareByCircleProvider->getSharesToCircles($teams) as $share) { - if (!array_key_exists($share->getId(), $shares)) { - $shares[$share->getSharedWith()] = []; - } + public function getSharedWithList(array $teams, string $resourceId): array { + $shares = $data = []; + foreach ($this->shareWrapperService->getSharesToCircles($teams, $resourceId) as $share) { $shares[$share->getSharedWith()][] = $share; } - foreach ($teams as $teamId) { - $data[$teamId] = $this->convertWrappedShareToResource($shares[$teamId]); + $data[$teamId] = $this->convertWrappedShareToResource($shares[$teamId] ?? []); } return $data; @@ -105,7 +101,7 @@ public function getTeamsForResource(string $resourceId): array { return []; } - $shares = $this->shareByCircleProvider->getSharesByFileId((int)$resourceId); + $shares = $this->shareWrapperService->getSharesByFileId((int)$resourceId); return array_map(function ($share) { return $share->getSharedWith(); diff --git a/lib/Service/ShareWrapperService.php b/lib/Service/ShareWrapperService.php index 936c512ac..fb2c023f2 100644 --- a/lib/Service/ShareWrapperService.php +++ b/lib/Service/ShareWrapperService.php @@ -116,8 +116,8 @@ public function getSharesToCircle( /** * @return ShareWrapper[] */ - public function getSharesToCircles(array $circleIds): array { - return $this->shareWrapperRequest->getSharesToCircles($circleIds); + public function getSharesToCircles(array $circleIds, ?string $fileId = null): array { + return $this->shareWrapperRequest->getSharesToCircles($circleIds, $fileId); } /**