Skip to content

Commit 8fe36b7

Browse files
fix(teams-api): adjust resource filtering
Signed-off-by: Cristian Scheid <cristianscheid@gmail.com>
1 parent 8f9b11e commit 8fe36b7

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

core/Controller/TeamsApiController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ public function resolveOne(string $teamId): DataResponse {
6666
public function listTeams(string $providerId, string $resourceId): DataResponse {
6767
/** @psalm-suppress PossiblyNullArgument The route is limited to logged-in users */
6868
$teams = $this->teamManager->getTeamsForResource($providerId, $resourceId, $this->userId);
69-
$sharesPerTeams = $this->teamManager->getSharedWithList(array_map(static fn (Team $team): string => $team->getId(), $teams), $this->userId);
69+
$teamIds = array_map(static fn (Team $team): string => $team->getId(), $teams);
70+
$sharesPerTeams = $this->teamManager->getSharedWithList($teamIds, $this->userId, $resourceId);
7071
$listTeams = array_values(array_map(static function (Team $team) use ($sharesPerTeams) {
7172
$response = $team->jsonSerialize();
7273
$response['resources'] = array_map(static fn (TeamResource $resource) => $resource->jsonSerialize(), $sharesPerTeams[$team->getId()] ?? []);

lib/private/Teams/TeamManager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,15 @@ public function getSharedWith(string $teamId, string $userId): array {
8484
return array_values($resources);
8585
}
8686

87-
public function getSharedWithList(array $teams, string $userId): array {
87+
public function getSharedWithList(array $teams, string $userId, string $resourceId): array {
8888
if (!$this->hasTeamSupport()) {
8989
return [];
9090
}
9191

9292
$resources = [];
9393
foreach ($this->getProviders() as $provider) {
9494
if (method_exists($provider, 'getSharedWithList')) {
95-
$resources[] = $provider->getSharedWithList($teams, $userId);
95+
$resources[] = $provider->getSharedWithList($teams, $resourceId);
9696
} else {
9797
foreach ($teams as $team) {
9898
$resources[] = [$team => $provider->getSharedWith($team)];

lib/public/Teams/ITeamManager.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,13 @@ public function getSharedWith(string $teamId, string $userId): array;
4242
public function getTeamsForResource(string $providerId, string $resourceId, string $userId): array;
4343

4444
/**
45-
* @param string[] $teams
46-
* @return array<string, list<TeamResource>>
45+
* Returns all team resources for the given teams, user and resource
4746
*
47+
* @return array<string, list<TeamResource>>
4848
* @since 33.0.0
49+
* @since 34.0.0 Added $resourceId param
4950
*/
50-
public function getSharedWithList(array $teams, string $userId): array;
51+
public function getSharedWithList(array $teams, string $userId, string $resourceId): array;
5152

5253
/**
5354
* Returns all teams that a given user is a member of

0 commit comments

Comments
 (0)