, array{}> * * 200: Statuses returned */ #[NoAdminRequired] #[ApiRoute(verb: 'GET', url: '/api/v1/statuses')] public function findAll(?int $limit = null, ?int $offset = null): DataResponse { $allStatuses = $this->service->findAll($limit, $offset); return new DataResponse(array_values(array_map(function ($userStatus) { return $this->formatStatus($userStatus); }, $allStatuses))); } /** * Find the status of a user * * @param string $userId ID of the user * @return DataResponse * @throws OCSNotFoundException The user was not found * * 200: Status returned */ #[NoAdminRequired] #[ApiRoute(verb: 'GET', url: '/api/v1/statuses/{userId}')] public function find(string $userId): DataResponse { try { $userStatus = $this->service->findByUserId($userId); } catch (DoesNotExistException $ex) { throw new OCSNotFoundException('No status for the requested userId'); } return new DataResponse($this->formatStatus($userStatus)); } /** * @param UserStatus $status * @return UserStatusPublic */ private function formatStatus(UserStatus $status): array { /** @var UserStatusType $visibleStatus */ $visibleStatus = $status->getStatus(); if ($visibleStatus === IUserStatus::INVISIBLE) { $visibleStatus = IUserStatus::OFFLINE; } return [ 'userId' => $status->getUserId(), 'message' => $status->getCustomMessage(), 'icon' => $status->getCustomIcon(), 'clearAt' => $status->getClearAt(), 'status' => $visibleStatus, ]; } }