diff options
author | Björn Schießle <bjoern@schiessle.org> | 2015-11-23 17:01:53 +0100 |
---|---|---|
committer | Björn Schießle <bjoern@schiessle.org> | 2015-11-24 11:34:38 +0100 |
commit | 964fa1fce3bc7734b6f7435f730e3b7394fc1cbf (patch) | |
tree | 6874e081ee2758fb9320f25ad5de9572f29f99ad /apps/federation/appinfo | |
parent | 7062e6636d52cae1ef086ab1f6caa97b10df3c0b (diff) | |
download | nextcloud-server-964fa1fce3bc7734b6f7435f730e3b7394fc1cbf.tar.gz nextcloud-server-964fa1fce3bc7734b6f7435f730e3b7394fc1cbf.zip |
use hooks to auto add server to the list of trusted servers once a federated share was created
Diffstat (limited to 'apps/federation/appinfo')
-rw-r--r-- | apps/federation/appinfo/app.php | 1 | ||||
-rw-r--r-- | apps/federation/appinfo/application.php | 19 |
2 files changed, 20 insertions, 0 deletions
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' + ); + } + } |