fix: Avoid throwing errors for teams are unavailable

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2024-06-14 12:08:10 +02:00
parent 8abf72b473
commit a3cec03f3a

View file

@ -52,6 +52,10 @@ class TeamManager implements ITeamManager {
}
public function getProviders(): array {
if (!$this->hasTeamSupport()) {
return [];
}
if ($this->providers !== null) {
return $this->providers;
}
@ -78,6 +82,10 @@ class TeamManager implements ITeamManager {
}
public function getSharedWith(string $teamId, string $userId): array {
if (!$this->hasTeamSupport()) {
return [];
}
if ($this->getTeam($teamId, $userId) === null) {
return [];
}
@ -92,6 +100,10 @@ class TeamManager implements ITeamManager {
}
public function getTeamsForResource(string $providerId, string $resourceId, string $userId): array {
if (!$this->hasTeamSupport()) {
return [];
}
$provider = $this->getProvider($providerId);
return array_values(array_filter(array_map(function ($teamId) use ($userId) {
$team = $this->getTeam($teamId, $userId);
@ -108,6 +120,10 @@ class TeamManager implements ITeamManager {
}
private function getTeam(string $teamId, string $userId): ?Circle {
if (!$this->hasTeamSupport()) {
return null;
}
try {
$federatedUser = $this->circlesManager->getFederatedUser($userId, Member::TYPE_USER);
$this->circlesManager->startSession($federatedUser);