12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- declare(strict_types=1);
- namespace OC\Core\Controller;
- use OCA\Core\ResponseDefinitions;
- use OCP\AppFramework\Http;
- use OCP\AppFramework\Http\Attribute\ApiRoute;
- use OCP\AppFramework\Http\Attribute\NoAdminRequired;
- use OCP\AppFramework\Http\DataResponse;
- use OCP\IRequest;
- use OCP\Teams\ITeamManager;
- use OCP\Teams\Team;
- class TeamsApiController extends \OCP\AppFramework\OCSController {
- public function __construct(
- string $appName,
- IRequest $request,
- private ITeamManager $teamManager,
- private ?string $userId,
- ) {
- parent::__construct($appName, $request);
- }
-
-
-
- public function resolveOne(string $teamId): DataResponse {
-
- $resolvedResources = $this->teamManager->getSharedWith($teamId, $this->userId);
- return new DataResponse(['resources' => $resolvedResources]);
- }
-
-
-
- public function listTeams(string $providerId, string $resourceId): DataResponse {
-
- $teams = $this->teamManager->getTeamsForResource($providerId, $resourceId, $this->userId);
-
- $teams = array_map(function (Team $team) {
- $response = $team->jsonSerialize();
-
- $response['resources'] = $this->teamManager->getSharedWith($team->getId(), $this->userId);
- return $response;
- }, $teams);
- return new DataResponse([
- 'teams' => $teams,
- ]);
- }
- }
|