aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2018-04-06 12:25:08 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2018-04-18 19:20:26 +0200
commit0b6e1974913580e6b17bbfb1b83259412529032e (patch)
tree09619bb789cc3abf30f9128f555fb725027d595c /apps/files_sharing
parenta0028a2a5f7f4df3f38eef2ba1a4552ff90f0269 (diff)
downloadnextcloud-server-0b6e1974913580e6b17bbfb1b83259412529032e.tar.gz
nextcloud-server-0b6e1974913580e6b17bbfb1b83259412529032e.zip
Add background job to refresh federated discovery
Once a day refresh the information automatically in cron Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/appinfo/info.xml3
-rw-r--r--apps/files_sharing/composer/composer/autoload_classmap.php1
-rw-r--r--apps/files_sharing/composer/composer/autoload_static.php1
-rw-r--r--apps/files_sharing/lib/BackgroundJob/FederatedSharesDiscoverJob.php56
4 files changed, 60 insertions, 1 deletions
diff --git a/apps/files_sharing/appinfo/info.xml b/apps/files_sharing/appinfo/info.xml
index b4c54247267..94a31bea63c 100644
--- a/apps/files_sharing/appinfo/info.xml
+++ b/apps/files_sharing/appinfo/info.xml
@@ -9,7 +9,7 @@
Turning the feature off removes shared files and folders on the server for all share recipients, and also on the sync clients and mobile apps. More information is available in the Nextcloud Documentation.
</description>
- <version>1.6.0</version>
+ <version>1.6.1</version>
<licence>agpl</licence>
<author>Michael Gapczynski</author>
<author>Bjoern Schiessle</author>
@@ -29,6 +29,7 @@ Turning the feature off removes shared files and folders on the server for all s
<background-jobs>
<job>OCA\Files_Sharing\DeleteOrphanedSharesJob</job>
<job>OCA\Files_Sharing\ExpireSharesJob</job>
+ <job>OCA\Files_Sharing\BackgroundJob\FederatedSharesDiscoverJob</job>
</background-jobs>
<repair-steps>
diff --git a/apps/files_sharing/composer/composer/autoload_classmap.php b/apps/files_sharing/composer/composer/autoload_classmap.php
index a68db3421b6..e5a86bbd095 100644
--- a/apps/files_sharing/composer/composer/autoload_classmap.php
+++ b/apps/files_sharing/composer/composer/autoload_classmap.php
@@ -17,6 +17,7 @@ return array(
'OCA\\Files_Sharing\\Activity\\Settings\\RemoteShare' => $baseDir . '/../lib/Activity/Settings/RemoteShare.php',
'OCA\\Files_Sharing\\Activity\\Settings\\Shared' => $baseDir . '/../lib/Activity/Settings/Shared.php',
'OCA\\Files_Sharing\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php',
+ 'OCA\\Files_Sharing\\BackgroundJob\\FederatedSharesDiscoverJob' => $baseDir . '/../lib/BackgroundJob/FederatedSharesDiscoverJob.php',
'OCA\\Files_Sharing\\Cache' => $baseDir . '/../lib/Cache.php',
'OCA\\Files_Sharing\\Capabilities' => $baseDir . '/../lib/Capabilities.php',
'OCA\\Files_Sharing\\Collaboration\\ShareRecipientSorter' => $baseDir . '/../lib/Collaboration/ShareRecipientSorter.php',
diff --git a/apps/files_sharing/composer/composer/autoload_static.php b/apps/files_sharing/composer/composer/autoload_static.php
index 328d6aca01d..bf41ef45ea1 100644
--- a/apps/files_sharing/composer/composer/autoload_static.php
+++ b/apps/files_sharing/composer/composer/autoload_static.php
@@ -32,6 +32,7 @@ class ComposerStaticInitFiles_Sharing
'OCA\\Files_Sharing\\Activity\\Settings\\RemoteShare' => __DIR__ . '/..' . '/../lib/Activity/Settings/RemoteShare.php',
'OCA\\Files_Sharing\\Activity\\Settings\\Shared' => __DIR__ . '/..' . '/../lib/Activity/Settings/Shared.php',
'OCA\\Files_Sharing\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php',
+ 'OCA\\Files_Sharing\\BackgroundJob\\FederatedSharesDiscoverJob' => __DIR__ . '/..' . '/../lib/BackgroundJob/FederatedSharesDiscoverJob.php',
'OCA\\Files_Sharing\\Cache' => __DIR__ . '/..' . '/../lib/Cache.php',
'OCA\\Files_Sharing\\Capabilities' => __DIR__ . '/..' . '/../lib/Capabilities.php',
'OCA\\Files_Sharing\\Collaboration\\ShareRecipientSorter' => __DIR__ . '/..' . '/../lib/Collaboration/ShareRecipientSorter.php',
diff --git a/apps/files_sharing/lib/BackgroundJob/FederatedSharesDiscoverJob.php b/apps/files_sharing/lib/BackgroundJob/FederatedSharesDiscoverJob.php
new file mode 100644
index 00000000000..6249eaca502
--- /dev/null
+++ b/apps/files_sharing/lib/BackgroundJob/FederatedSharesDiscoverJob.php
@@ -0,0 +1,56 @@
+<?php
+declare(strict_types=1);
+/**
+ * @copyright 2018, Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+namespace OCA\Files_Sharing\BackgroundJob;
+
+use OC\BackgroundJob\TimedJob;
+use OCP\IDBConnection;
+use OCP\OCS\IDiscoveryService;
+
+class FederatedSharesDiscoverJob extends TimedJob {
+ /** @var IDBConnection */
+ private $connection;
+ /** @var IDiscoveryService */
+ private $discoveryService;
+
+ public function __construct(IDBConnection $connection,
+ IDiscoveryService $discoveryService) {
+ $this->connection = $connection;
+ $this->discoveryService = $discoveryService;
+
+ $this->setInterval(86400);
+ }
+
+ public function run($argument) {
+ $qb = $this->connection->getQueryBuilder();
+
+ $qb->selectDistinct('remote')
+ ->from('share_external');
+
+ $result = $qb->execute();
+ while($row = $result->fetch()) {
+ $this->discoveryService->discover($row['remote'], 'FEDERATED_SHARING', true);
+ }
+ $result->closeCursor();
+ }
+}