mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
fix(teams-api): adjust resource filtering
Signed-off-by: Cristian Scheid <cristianscheid@gmail.com>
This commit is contained in:
parent
8f9b11ef0b
commit
8fe36b7c19
3 changed files with 8 additions and 6 deletions
|
|
@ -66,7 +66,8 @@ class TeamsApiController extends OCSController {
|
|||
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()] ?? []);
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ class TeamManager implements ITeamManager {
|
|||
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 [];
|
||||
}
|
||||
|
|
@ -92,7 +92,7 @@ class TeamManager implements ITeamManager {
|
|||
$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)];
|
||||
|
|
|
|||
|
|
@ -42,12 +42,13 @@ interface ITeamManager {
|
|||
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 34.0.0 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
|
||||
|
|
|
|||
Loading…
Reference in a new issue