Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions lib/Db/ShareWrapperRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,18 +182,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);
}

Expand Down
18 changes: 7 additions & 11 deletions lib/FileSharingTeamResourceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {
}
Expand All @@ -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<string, TeamResource[]>
*/
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;
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions lib/Service/ShareWrapperService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
Loading