Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ONLYOFFICE/onlyoffice-nextcloud.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/fileutility.php')
-rw-r--r--lib/fileutility.php42
1 files changed, 3 insertions, 39 deletions
diff --git a/lib/fileutility.php b/lib/fileutility.php
index 2d2a65f..cc50a45 100644
--- a/lib/fileutility.php
+++ b/lib/fileutility.php
@@ -27,10 +27,9 @@ use OCP\ILogger;
use OCP\ISession;
use OCP\Share\IManager;
-use OCA\Files_Sharing\External\Storage as SharingExternalStorage;
-
use OCA\Onlyoffice\AppConfig;
use OCA\Onlyoffice\KeyManager;
+use OCA\Onlyoffice\RemoteInstance;
/**
* File utility
@@ -221,10 +220,10 @@ class FileUtility {
$fileId = $file->getId();
if ($origin
- && $file->getStorage()->instanceOfStorage(SharingExternalStorage::class)) {
+ && RemoteInstance::isRemoteFile($file)) {
try {
- $key = $this->getFederatedKey($file);
+ $key = RemoteInstance::getRemoteKey($file);
if (!empty($key)) {
return $key;
@@ -263,41 +262,6 @@ class FileUtility {
}
/**
- * Generate unique document identifier in federated share
- *
- * @param File $file - file
- *
- * @return string
- */
- private function getFederatedKey($file) {
- $remote = rtrim($file->getStorage()->getRemote(), "/") . "/";
- $shareToken = $file->getStorage()->getToken();
- $internalPath = $file->getInternalPath();
-
- $httpClientService = \OC::$server->getHTTPClientService();
- $client = $httpClientService->newClient();
- $response = $client->post($remote . "ocs/v2.php/apps/" . $this->appName . "/api/v1/key?format=json", [
- "timeout" => 5,
- "body" => [
- "shareToken" => $shareToken,
- "path" => $internalPath
- ]
- ]);
- $body = \json_decode($response->getBody(), true);
-
- $data = $body["ocs"]["data"];
- if (!empty($data["error"])) {
- $this->logger->error("Error federated key " . $data["error"], ["app" => $this->appName]);
- return null;
- }
-
- $key = $data["key"];
- $this->logger->debug("Federated key: $key", ["app" => $this->appName]);
-
- return $key;
- }
-
- /**
* Generate unique file version key
*
* @param OCA\Files_Versions\Versions\IVersion $version - file version