From 964fa1fce3bc7734b6f7435f730e3b7394fc1cbf Mon Sep 17 00:00:00 2001 From: Björn Schießle Date: Mon, 23 Nov 2015 17:01:53 +0100 Subject: use hooks to auto add server to the list of trusted servers once a federated share was created --- apps/federation/appinfo/app.php | 1 + apps/federation/appinfo/application.php | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) (limited to 'apps/federation/appinfo') diff --git a/apps/federation/appinfo/app.php b/apps/federation/appinfo/app.php index 9ed00f23866..8cc77885d6f 100644 --- a/apps/federation/appinfo/app.php +++ b/apps/federation/appinfo/app.php @@ -23,3 +23,4 @@ namespace OCA\Federation\AppInfo; $app = new Application(); $app->registerSettings(); +$app->registerHooks(); diff --git a/apps/federation/appinfo/application.php b/apps/federation/appinfo/application.php index 350b140b4dd..5be23253209 100644 --- a/apps/federation/appinfo/application.php +++ b/apps/federation/appinfo/application.php @@ -25,11 +25,13 @@ use OCA\Federation\API\OCSAuthAPI; use OCA\Federation\Controller\AuthController; use OCA\Federation\Controller\SettingsController; use OCA\Federation\DbHandler; +use OCA\Federation\Hooks; use OCA\Federation\Middleware\AddServerMiddleware; use OCA\Federation\TrustedServers; use OCP\API; use OCP\App; use OCP\AppFramework\IAppContainer; +use OCP\Util; class Application extends \OCP\AppFramework\App { @@ -127,4 +129,21 @@ class Application extends \OCP\AppFramework\App { } + /** + * listen to federated_share_added hooks to auto-add new servers to the + * list of trusted servers. + */ + public function registerHooks() { + + $container = $this->getContainer(); + $hooksManager = new Hooks($container->query('TrustedServers')); + + Util::connectHook( + 'OCP\Share', + 'federated_share_added', + $hooksManager, + 'addServerHook' + ); + } + } -- cgit v1.2.3