registerService(ExternalMountProvider::class, function (ContainerInterface $c) { return new ExternalMountProvider( $c->get(IDBConnection::class), function () use ($c) { return $c->get(Manager::class); }, $c->get(ICloudIdManager::class) ); }); /** * Middleware */ $context->registerMiddleWare(SharingCheckMiddleware::class); $context->registerMiddleWare(OCSShareAPIMiddleware::class); $context->registerMiddleWare(ShareInfoMiddleware::class); $context->registerCapability(Capabilities::class); $context->registerNotifierService(Notifier::class); $context->registerEventListener(UserChangedEvent::class, DisplayNameCache::class); $context->registerEventListener(UserDeletedEvent::class, DisplayNameCache::class); $context->registerEventListener(GroupChangedEvent::class, GroupDisplayNameCache::class); $context->registerEventListener(GroupDeletedEvent::class, GroupDisplayNameCache::class); // Sidebar and files scripts $context->registerEventListener(LoadAdditionalScriptsEvent::class, LoadAdditionalListener::class); $context->registerEventListener(LoadSidebar::class, LoadSidebarListener::class); $context->registerEventListener(ShareCreatedEvent::class, ShareInteractionListener::class); $context->registerEventListener(ShareCreatedEvent::class, UserShareAcceptanceListener::class); $context->registerEventListener(UserAddedEvent::class, UserAddedToGroupListener::class); // Handle download events for view only checks $context->registerEventListener(BeforeZipCreatedEvent::class, BeforeZipCreatedListener::class); $context->registerEventListener(BeforeDirectFileDownloadEvent::class, BeforeDirectFileDownloadListener::class); // File request auth $context->registerEventListener(BeforeTemplateRenderedEvent::class, LoadPublicFileRequestAuthListener::class); } public function boot(IBootContext $context): void { $context->injectFn([$this, 'registerMountProviders']); $context->injectFn([$this, 'registerEventsScripts']); Helper::registerHooks(); Share::registerBackend('file', File::class); Share::registerBackend('folder', Folder::class, 'file'); } public function registerMountProviders(IMountProviderCollection $mountProviderCollection, MountProvider $mountProvider, ExternalMountProvider $externalMountProvider): void { $mountProviderCollection->registerProvider($mountProvider); $mountProviderCollection->registerProvider($externalMountProvider); } public function registerEventsScripts(IEventDispatcher $dispatcher): void { $dispatcher->addListener(ResourcesLoadAdditionalScriptsEvent::class, function () { \OCP\Util::addScript('files_sharing', 'collaboration'); }); $dispatcher->addListener(\OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent::class, function () { /** * Always add main sharing script */ Util::addScript(self::APP_ID, 'main'); }); // notifications api to accept incoming user shares $dispatcher->addListener(ShareCreatedEvent::class, function (ShareCreatedEvent $event) { /** @var Listener $listener */ $listener = $this->getContainer()->query(Listener::class); $listener->shareNotification($event); }); $dispatcher->addListener(IGroup::class . '::postAddUser', function ($event) { if (!$event instanceof OldGenericEvent) { return; } /** @var Listener $listener */ $listener = $this->getContainer()->query(Listener::class); $listener->userAddedToGroup($event); }); } }