aboutsummaryrefslogtreecommitdiffstats
path: root/apps/federatedfilesharing/lib
diff options
context:
space:
mode:
authorBjoern Schiessle <bjoern@schiessle.org>2018-06-25 11:40:16 +0200
committerBjoern Schiessle <bjoern@schiessle.org>2018-07-11 10:11:41 +0200
commitc8631d607ef827f0eb29312faf7b2b808e1a8e7d (patch)
tree1ef1aec833e6f6ada8c77c3388a5ff059175b039 /apps/federatedfilesharing/lib
parenta22bc0e78758a86000b1023c93e554ebca696493 (diff)
downloadnextcloud-server-c8631d607ef827f0eb29312faf7b2b808e1a8e7d.tar.gz
nextcloud-server-c8631d607ef827f0eb29312faf7b2b808e1a8e7d.zip
add setting to enable/disable federated group sharing
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'apps/federatedfilesharing/lib')
-rw-r--r--apps/federatedfilesharing/lib/FederatedShareProvider.php45
-rw-r--r--apps/federatedfilesharing/lib/Settings/Admin.php3
2 files changed, 47 insertions, 1 deletions
diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php
index f81b826f12c..d32560c4ffd 100644
--- a/apps/federatedfilesharing/lib/FederatedShareProvider.php
+++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php
@@ -30,6 +30,7 @@
namespace OCA\FederatedFileSharing;
use OC\Share20\Share;
+use OCP\Federation\ICloudFederationProviderManager;
use OCP\Federation\ICloudIdManager;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\Files\Folder;
@@ -92,6 +93,9 @@ class FederatedShareProvider implements IShareProvider {
/** @var \OCP\GlobalScale\IConfig */
private $gsConfig;
+ /** @var ICloudFederationProviderManager */
+ private $cloudFederationProviderManager;
+
/**
* DefaultShareProvider constructor.
*
@@ -106,6 +110,7 @@ class FederatedShareProvider implements IShareProvider {
* @param IUserManager $userManager
* @param ICloudIdManager $cloudIdManager
* @param \OCP\GlobalScale\IConfig $globalScaleConfig
+ * @param ICloudFederationProviderManager $cloudFederationProviderManager
*/
public function __construct(
IDBConnection $connection,
@@ -118,7 +123,8 @@ class FederatedShareProvider implements IShareProvider {
IConfig $config,
IUserManager $userManager,
ICloudIdManager $cloudIdManager,
- \OCP\GlobalScale\IConfig $globalScaleConfig
+ \OCP\GlobalScale\IConfig $globalScaleConfig,
+ ICloudFederationProviderManager $cloudFederationProviderManager
) {
$this->dbConnection = $connection;
$this->addressHandler = $addressHandler;
@@ -131,6 +137,7 @@ class FederatedShareProvider implements IShareProvider {
$this->userManager = $userManager;
$this->cloudIdManager = $cloudIdManager;
$this->gsConfig = $globalScaleConfig;
+ $this->cloudFederationProviderManager = $cloudFederationProviderManager;
}
/**
@@ -967,6 +974,42 @@ class FederatedShareProvider implements IShareProvider {
return ($result === 'yes');
}
+
+ /**
+ * check if users from other Nextcloud instances are allowed to send federated group shares
+ *
+ * @return bool
+ */
+ public function isOutgoingServer2serverGroupShareEnabled() {
+ if ($this->gsConfig->onlyInternalFederation()) {
+ return false;
+ }
+ $result = $this->config->getAppValue('files_sharing', 'outgoing_server2server_group_share_enabled', 'no');
+ return ($result === 'yes');
+ }
+
+ /**
+ * check if users are allowed to receive federated group shares
+ *
+ * @return bool
+ */
+ public function isIncomingServer2serverGroupShareEnabled() {
+ if ($this->gsConfig->onlyInternalFederation()) {
+ return false;
+ }
+ $result = $this->config->getAppValue('files_sharing', 'incoming_server2server_group_share_enabled', 'no');
+ return ($result === 'yes');
+ }
+
+ /**
+ * check if federated group sharing is supported, therefore the OCM API need to be enabled
+ *
+ * @return bool
+ */
+ public function isFederatedGroupSharingSupported() {
+ return $this->cloudFederationProviderManager->isReady();
+ }
+
/**
* Check if querying sharees on the lookup server is enabled
*
diff --git a/apps/federatedfilesharing/lib/Settings/Admin.php b/apps/federatedfilesharing/lib/Settings/Admin.php
index cbeaa167fff..aea7957a49f 100644
--- a/apps/federatedfilesharing/lib/Settings/Admin.php
+++ b/apps/federatedfilesharing/lib/Settings/Admin.php
@@ -58,6 +58,9 @@ class Admin implements ISettings {
'internalOnly' => $this->gsConfig->onlyInternalFederation(),
'outgoingServer2serverShareEnabled' => $this->fedShareProvider->isOutgoingServer2serverShareEnabled(),
'incomingServer2serverShareEnabled' => $this->fedShareProvider->isIncomingServer2serverShareEnabled(),
+ 'federatedGroupSharingSupported' => $this->fedShareProvider->isFederatedGroupSharingSupported(),
+ 'outgoingServer2serverGroupShareEnabled' => $this->fedShareProvider->isOutgoingServer2serverGroupShareEnabled(),
+ 'incomingServer2serverGroupShareEnabled' => $this->fedShareProvider->isIncomingServer2serverGroupShareEnabled(),
'lookupServerEnabled' => $this->fedShareProvider->isLookupServerQueriesEnabled(),
'lookupServerUploadEnabled' => $this->fedShareProvider->isLookupServerUploadEnabled(),
];