actorRepository = $actorRepository; $this->actorStoreFactory = $actorStoreFactory; } /** * {@inheritdoc} */ protected function action(): Response { $params = $this->request->getQueryParams(); $didParam = $params['did'] ?? null; if (!is_string($didParam) || trim($didParam) === '') { $this->throwMissingKeyException('did'); } $did = trim($didParam); if (!Did::isValid($did)) { throw XrpcException::invalidParam($this->actionName, 'Invalid DID', $did); } try { $actor = $this->actorRepository->findActorByDid($did); } catch (ActorNotFoundException $e) { throw $this->namedError('RepoNotFound', sprintf('Could not find repo for DID: %s', $did)); } $status = $actor->getRepoStatus(); if ($status === RepoView::STATUS_TAKENDOWN) { throw $this->namedError('RepoTakendown', sprintf('Repo has been taken down: %s', $did)); } if ($status === RepoView::STATUS_DEACTIVATED) { throw $this->namedError('RepoDeactivated', sprintf('Repo has been deactivated: %s', $did)); } try { $root = $this->actorStoreFactory->get($did)->getRepoRoot()->findByDid($did); } catch (RepoRootNotFoundException $e) { throw $this->namedError('RepoNotFound', sprintf('Could not find root for DID: %s', $did)); } return $this->respondWithData(new GetLatestCommitResponse( cid: $root->getCid(), rev: $root->getRev(), )); } private function namedError(string $error, string $message): XrpcException { return new XrpcException( $error, $message, StatusCodeInterface::STATUS_BAD_REQUEST ); } }