summaryrefslogtreecommitdiffstats
path: root/apps/federation/lib/trustedservers.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/federation/lib/trustedservers.php')
-rw-r--r--apps/federation/lib/trustedservers.php31
1 files changed, 30 insertions, 1 deletions
diff --git a/apps/federation/lib/trustedservers.php b/apps/federation/lib/trustedservers.php
index f3ac6e24fc6..96a29178076 100644
--- a/apps/federation/lib/trustedservers.php
+++ b/apps/federation/lib/trustedservers.php
@@ -25,6 +25,7 @@ namespace OCA\Federation;
use OCP\AppFramework\Http;
use OCP\BackgroundJob\IJobList;
use OCP\Http\Client\IClientService;
+use OCP\IConfig;
use OCP\ILogger;
use OCP\Security\ISecureRandom;
@@ -52,25 +53,31 @@ class TrustedServers {
/** @var ISecureRandom */
private $secureRandom;
+ /** @var IConfig */
+ private $config;
+
/**
* @param DbHandler $dbHandler
* @param IClientService $httpClientService
* @param ILogger $logger
* @param IJobList $jobList
* @param ISecureRandom $secureRandom
+ * @param IConfig $config
*/
public function __construct(
DbHandler $dbHandler,
IClientService $httpClientService,
ILogger $logger,
IJobList $jobList,
- ISecureRandom $secureRandom
+ ISecureRandom $secureRandom,
+ IConfig $config
) {
$this->dbHandler = $dbHandler;
$this->httpClientService = $httpClientService;
$this->logger = $logger;
$this->jobList = $jobList;
$this->secureRandom = $secureRandom;
+ $this->config = $config;
}
/**
@@ -98,6 +105,28 @@ class TrustedServers {
}
/**
+ * enable/disable to automatically add servers to the list of trusted servers
+ * once a federated share was created and accepted successfully
+ *
+ * @param bool $status
+ */
+ public function setAutoAddServers($status) {
+ $value = $status ? '1' : '0';
+ $this->config->setAppValue('federation', 'autoAddServers', $value);
+ }
+
+ /**
+ * return if we automatically add servers to the list of trusted servers
+ * once a federated share was created and accepted successfully
+ *
+ * @return bool
+ */
+ public function getAutoAddServers() {
+ $value = $this->config->getAppValue('federation', 'autoAddServers', '1');
+ return $value === '1';
+ }
+
+ /**
* get shared secret for the given server
*
* @param string $url