From 93a080c492df907a3440558e6dc599021ff98672 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 29 Oct 2021 15:18:57 +0200 Subject: [PATCH] Correctly register the cloud federation provider Signed-off-by: Joas Schilling --- lib/AppInfo/Application.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index dca18aaff1e..a85d6f7d785 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -44,6 +44,7 @@ use OCA\Talk\Events\AttendeesRemovedEvent; use OCA\Talk\Events\ChatEvent; use OCA\Talk\Events\RoomEvent; +use OCA\Talk\Federation\CloudFederationProviderTalk; use OCA\Talk\Files\Listener as FilesListener; use OCA\Talk\Files\TemplateLoader as FilesTemplateLoader; use OCA\Talk\Flow\RegisterOperationsListener; @@ -79,12 +80,16 @@ use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; use OCP\AppFramework\Bootstrap\IRegistrationContext; +use OCP\AppFramework\IAppContainer; use OCP\AppFramework\Utility\ITimeFactory; use OCP\Collaboration\Resources\IProviderManager; use OCP\EventDispatcher\IEventDispatcher; +use OCP\Federation\ICloudFederationProvider; +use OCP\Federation\ICloudFederationProviderManager; use OCP\Group\Events\GroupDeletedEvent; use OCP\Group\Events\UserAddedEvent; use OCP\Group\Events\UserRemovedEvent; +use OCP\IConfig; use OCP\IServerContainer; use OCP\IUser; use OCP\Security\CSP\AddContentSecurityPolicyEvent; @@ -166,6 +171,7 @@ public function boot(IBootContext $context): void { $this->registerRoomActivityHooks($dispatcher); $this->registerChatHooks($dispatcher); + $context->injectFn(\Closure::fromCallable([$this, 'registerCloudFederationProviderManager'])); } protected function registerNotifier(IServerContainer $server): void { @@ -226,4 +232,21 @@ protected function registerChatHooks(IEventDispatcher $dispatcher): void { }; $dispatcher->addListener(Room::EVENT_AFTER_ROOM_DELETE, $listener); } + + protected function registerCloudFederationProviderManager( + IConfig $config, + ICloudFederationProviderManager $manager, + IAppContainer $appContainer): void { + if ($config->getAppValue('spreed', 'federation_enabled', 'no') !== 'yes') { + return; + } + + $manager->addCloudFederationProvider( + 'talk-room', + 'Talk Federation', + static function () use ($appContainer): ICloudFederationProvider { + return $appContainer->get(CloudFederationProviderTalk::class); + } + ); + } }