Skip to content

Commit

Permalink
Correctly register the cloud federation provider
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Nov 3, 2021
1 parent 214cf55 commit 93a080c
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}
);
}
}

0 comments on commit 93a080c

Please sign in to comment.