logger = $logger; $this->config = \OCP\Server::get(AppConfig::class); $this->fileUtility = new FileUtility($AppName, $trans, $logger, $this->config, $shareManager, $session); } /** * Returns the origin document key for editor * * @param string $shareToken - access token * @param string $path - file path * * @return DataResponse */ #[NoAdminRequired] #[NoCSRFRequired] #[PublicPage] public function key($shareToken, $path) { list($file, $error, $share) = $this->fileUtility->getFileByToken(null, $shareToken, $path); if (isset($error)) { $this->logger->error("Federated getFileByToken: $error"); return new DataResponse(["error" => $error]); } $key = $this->fileUtility->getKey($file, true); $key = DocumentService::generateRevisionId($key); $this->logger->debug("Federated request get for " . $file->getId() . " key $key"); return new DataResponse(["key" => $key]); } /** * Lock the origin document key for editor * * @param string $shareToken - access token * @param string $path - file path * @param bool $lock - status * @param bool $fs - status * * @return DataResponse */ #[NoAdminRequired] #[NoCSRFRequired] #[PublicPage] public function keylock($shareToken, $path, $lock, $fs) { list($file, $error, $share) = $this->fileUtility->getFileByToken(null, $shareToken, $path); if (isset($error)) { $this->logger->error("Federated getFileByToken: $error"); return new DataResponse(["error" => $error]); } $fileId = $file->getId(); if (RemoteInstance::isRemoteFile($file)) { $isLock = RemoteInstance::lockRemoteKey($file, $lock, $fs); if (!$isLock) { return new DataResponse(["error" => "Failed request"]); } } else { KeyManager::lock($fileId, $lock); if (!empty($fs)) { KeyManager::setForcesave($fileId, $fs); } } $this->logger->debug("Federated request lock for " . $fileId); return new DataResponse(); } /** * Health check instance * * @return DataResponse */ #[NoAdminRequired] #[NoCSRFRequired] #[PublicPage] public function healthcheck() { $this->logger->debug("Federated healthcheck"); return new DataResponse(["alive" => true]); } }