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
3 changes: 2 additions & 1 deletion core/Controller/TeamsApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ public function resolveOne(string $teamId): DataResponse {
public function listTeams(string $providerId, string $resourceId): DataResponse {
/** @psalm-suppress PossiblyNullArgument The route is limited to logged-in users */
$teams = $this->teamManager->getTeamsForResource($providerId, $resourceId, $this->userId);
$sharesPerTeams = $this->teamManager->getSharedWithList(array_map(static fn (Team $team): string => $team->getId(), $teams), $this->userId);
$teamIds = array_map(static fn (Team $team): string => $team->getId(), $teams);
$sharesPerTeams = $this->teamManager->getSharedWithList($teamIds, $this->userId, $resourceId);
$listTeams = array_values(array_map(static function (Team $team) use ($sharesPerTeams) {
$response = $team->jsonSerialize();
$response['resources'] = array_map(static fn (TeamResource $resource) => $resource->jsonSerialize(), $sharesPerTeams[$team->getId()] ?? []);
Expand Down
4 changes: 2 additions & 2 deletions lib/private/Teams/TeamManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ public function getSharedWith(string $teamId, string $userId): array {
return array_values($resources);
}

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

$resources = [];
foreach ($this->getProviders() as $provider) {
if (method_exists($provider, 'getSharedWithList')) {
$resources[] = $provider->getSharedWithList($teams, $userId);
$resources[] = $provider->getSharedWithList($teams, $resourceId);
} else {
foreach ($teams as $team) {
$resources[] = [$team => $provider->getSharedWith($team)];
Expand Down
7 changes: 4 additions & 3 deletions lib/public/Teams/ITeamManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ public function getSharedWith(string $teamId, string $userId): array;
public function getTeamsForResource(string $providerId, string $resourceId, string $userId): array;

/**
* @param string[] $teams
* @return array<string, list<TeamResource>>
* Returns all team resources for the given teams, user and resource
*
* @return array<string, list<TeamResource>>
* @since 33.0.0
* @since 33.0.3 Added $resourceId param
*/
public function getSharedWithList(array $teams, string $userId): array;
public function getSharedWithList(array $teams, string $userId, string $resourceId): array;

/**
* Returns all teams that a given user is a member of
Expand Down
Loading