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

github.com/nextcloud/richdocuments.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Service/FederationService.php')
-rw-r--r--lib/Service/FederationService.php25
1 files changed, 21 insertions, 4 deletions
diff --git a/lib/Service/FederationService.php b/lib/Service/FederationService.php
index 403df2c1..5d00c5e6 100644
--- a/lib/Service/FederationService.php
+++ b/lib/Service/FederationService.php
@@ -1,4 +1,7 @@
<?php
+
+declare(strict_types=1);
+
/**
* @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net>
*
@@ -29,7 +32,7 @@ use OCA\Richdocuments\AppConfig;
use OCA\Richdocuments\Db\Direct;
use OCA\Richdocuments\Db\Wopi;
use OCA\Richdocuments\TokenManager;
-use OCP\AppFramework\QueryException;
+use OCP\AutoloadNotAllowedException;
use OCP\Files\File;
use OCP\Files\InvalidPathException;
use OCP\Files\NotFoundException;
@@ -40,6 +43,8 @@ use OCP\ILogger;
use OCP\IRequest;
use OCP\IURLGenerator;
use OCP\Share\IShare;
+use Psr\Container\ContainerExceptionInterface;
+use Psr\Container\NotFoundExceptionInterface;
class FederationService {
@@ -69,9 +74,21 @@ class FederationService {
$this->request = $request;
$this->urlGenerator = $urlGenerator;
try {
- $this->trustedServers = \OC::$server->query(\OCA\Federation\TrustedServers::class);
- } catch (QueryException $e) {
+ $this->trustedServers = \OC::$server->get(\OCA\Federation\TrustedServers::class);
+ } catch (NotFoundExceptionInterface $e) {
+ } catch (ContainerExceptionInterface $e) {
+ } catch (AutoloadNotAllowedException $e) {
+ }
+ }
+
+ public function getTrustedServers(): array {
+ if (!$this->trustedServers) {
+ return [];
}
+
+ return array_map(function (array $server) {
+ return $server['url'];
+ }, $this->trustedServers->getServers());
}
/**
@@ -118,7 +135,7 @@ class FederationService {
$domain = $this->getDomainWithoutPort($domainWithPort);
- $trustedList = array_merge($this->appConfig->getTrustedDomains(), [$this->request->getServerHost()]);
+ $trustedList = array_merge($this->appConfig->getGlobalScaleTrustedHosts(), [$this->request->getServerHost()]);
if (!is_array($trustedList)) {
return false;
}