Skip to content

Commit f77bcdf

Browse files
authored
Merge pull request #2467 from nextcloud/backport/2458/stable33
[stable33] fix(shared-with-list): adjust resource filtering
2 parents 3593aeb + 880d642 commit f77bcdf

3 files changed

Lines changed: 14 additions & 20 deletions

File tree

lib/Db/ShareWrapperRequest.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,18 +183,16 @@ public function getSharesToCircle(
183183

184184

185185
/**
186-
* @param string $circleId
187-
* @param FederatedUser|null $shareRecipient
188-
* @param FederatedUser|null $shareInitiator
189-
* @param bool $completeDetails
190-
*
191186
* @return ShareWrapper[]
192187
* @throws RequestBuilderException
193188
*/
194-
public function getSharesToCircles(array $circleIds): array {
189+
public function getSharesToCircles(array $circleIds, ?string $fileId = null): array {
195190
$qb = $this->getShareSelectSql();
196191
$qb->limitNull('parent', false);
197-
$qb->expr()->in('share_with', $qb->createNamedParameter($circleIds, IQueryBuilder::PARAM_STR_ARRAY));
192+
$qb->andWhere($qb->expr()->in('share_with', $qb->createNamedParameter($circleIds, IQueryBuilder::PARAM_STR_ARRAY)));
193+
if ($fileId !== null) {
194+
$qb->limitToFileSource((int)$fileId);
195+
}
198196
return $this->getItemsFromRequest($qb);
199197
}
200198

lib/FileSharingTeamResourceProvider.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class FileSharingTeamResourceProvider implements ITeamResourceProvider {
2020
public function __construct(
2121
private IL10N $l10n,
2222
private ?CirclesManager $circlesManager,
23-
private ShareWrapperService $shareByCircleProvider,
23+
private ShareWrapperService $shareWrapperService,
2424
private IURLGenerator $urlGenerator,
2525
) {
2626
}
@@ -42,24 +42,20 @@ public function getSharedWith(string $teamId): array {
4242
return [];
4343
}
4444

45-
$shares = $this->shareByCircleProvider->getSharesToCircle($teamId);
45+
$shares = $this->shareWrapperService->getSharesToCircle($teamId);
4646
return $this->convertWrappedShareToResource($shares);
4747
}
4848

4949
/**
5050
* @return array<string, TeamResource[]>
5151
*/
52-
public function getSharedWithList(array $teams): array {
53-
$data = $shares = [];
54-
foreach ($this->shareByCircleProvider->getSharesToCircles($teams) as $share) {
55-
if (!array_key_exists($share->getId(), $shares)) {
56-
$shares[$share->getSharedWith()] = [];
57-
}
52+
public function getSharedWithList(array $teams, string $resourceId): array {
53+
$shares = $data = [];
54+
foreach ($this->shareWrapperService->getSharesToCircles($teams, $resourceId) as $share) {
5855
$shares[$share->getSharedWith()][] = $share;
5956
}
60-
6157
foreach ($teams as $teamId) {
62-
$data[$teamId] = $this->convertWrappedShareToResource($shares[$teamId]);
58+
$data[$teamId] = $this->convertWrappedShareToResource($shares[$teamId] ?? []);
6359
}
6460

6561
return $data;
@@ -105,7 +101,7 @@ public function getTeamsForResource(string $resourceId): array {
105101
return [];
106102
}
107103

108-
$shares = $this->shareByCircleProvider->getSharesByFileId((int)$resourceId);
104+
$shares = $this->shareWrapperService->getSharesByFileId((int)$resourceId);
109105

110106
return array_map(function ($share) {
111107
return $share->getSharedWith();

lib/Service/ShareWrapperService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ public function getSharesToCircle(
116116
/**
117117
* @return ShareWrapper[]
118118
*/
119-
public function getSharesToCircles(array $circleIds): array {
120-
return $this->shareWrapperRequest->getSharesToCircles($circleIds);
119+
public function getSharesToCircles(array $circleIds, ?string $fileId = null): array {
120+
return $this->shareWrapperRequest->getSharesToCircles($circleIds, $fileId);
121121
}
122122

123123
/**

0 commit comments

Comments
 (0)