diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2020-06-18 22:25:23 +0300 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2020-07-07 21:43:46 +0300 |
commit | 43121485379a09384d6793b1380953d4d72579c7 (patch) | |
tree | b03469c4f3b24cddf7bfac6fcacbdd31d3a41864 | |
parent | 616e8a6c56861e97a84906a3566b3840c97e1988 (diff) |
fixup! First app interface to publish to pushenh/mercure/push
-rw-r--r-- | lib/composer/composer/autoload_classmap.php | 3 | ||||
-rw-r--r-- | lib/composer/composer/autoload_static.php | 3 | ||||
-rw-r--r-- | lib/private/AppFramework/Bootstrap/Coordinator.php | 7 | ||||
-rw-r--r-- | lib/private/AppFramework/Bootstrap/RegistrationContext.php | 44 | ||||
-rw-r--r-- | lib/private/Push/Manager.php | 2 | ||||
-rw-r--r-- | lib/private/Server.php | 2 | ||||
-rw-r--r-- | lib/public/AppFramework/Bootstrap/IRegistrationContext.php | 29 | ||||
-rw-r--r-- | lib/public/Push/IManager.php | 50 |
8 files changed, 85 insertions, 55 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 1effb0b26b9..4bc660263a9 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -419,7 +419,6 @@ return array( 'OCP\\Preview\\IProvider' => $baseDir . '/lib/public/Preview/IProvider.php', 'OCP\\Preview\\IProviderV2' => $baseDir . '/lib/public/Preview/IProviderV2.php', 'OCP\\Preview\\IVersionedPreviewFile' => $baseDir . '/lib/public/Preview/IVersionedPreviewFile.php', - 'OCP\\Push\\IManager' => $baseDir . '/lib/public/Push/IManager.php', 'OCP\\Push\\IPush' => $baseDir . '/lib/public/Push/IPush.php', 'OCP\\Push\\IPushApp' => $baseDir . '/lib/public/Push/IPushApp.php', 'OCP\\Push\\IValidateAccess' => $baseDir . '/lib/public/Push/IValidateAccess.php', @@ -595,6 +594,7 @@ return array( 'OC\\AppFramework\\Routing\\RouteConfig' => $baseDir . '/lib/private/AppFramework/Routing/RouteConfig.php', 'OC\\AppFramework\\Services\\AppConfig' => $baseDir . '/lib/private/AppFramework/Services/AppConfig.php', 'OC\\AppFramework\\Services\\InitialState' => $baseDir . '/lib/private/AppFramework/Services/InitialState.php', + 'OC\\AppFramework\\Services\\Push' => $baseDir . '/lib/private/AppFramework/Services/Push.php', 'OC\\AppFramework\\Utility\\ControllerMethodReflector' => $baseDir . '/lib/private/AppFramework/Utility/ControllerMethodReflector.php', 'OC\\AppFramework\\Utility\\SimpleContainer' => $baseDir . '/lib/private/AppFramework/Utility/SimpleContainer.php', 'OC\\AppFramework\\Utility\\TimeFactory' => $baseDir . '/lib/private/AppFramework/Utility/TimeFactory.php', @@ -1207,6 +1207,7 @@ return array( 'OC\\Preview\\WatcherConnector' => $baseDir . '/lib/private/Preview/WatcherConnector.php', 'OC\\Preview\\XBitmap' => $baseDir . '/lib/private/Preview/XBitmap.php', 'OC\\Push\\Manager' => $baseDir . '/lib/private/Push/Manager.php', + 'OC\\Push\\Push' => $baseDir . '/lib/private/Push/Push.php', 'OC\\Push\\VoidPushApp' => $baseDir . '/lib/private/Push/VoidPushApp.php', 'OC\\RedisFactory' => $baseDir . '/lib/private/RedisFactory.php', 'OC\\Remote\\Api\\ApiBase' => $baseDir . '/lib/private/Remote/Api/ApiBase.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 77a78c839d7..c6107d7c39b 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -448,7 +448,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OCP\\Preview\\IProvider' => __DIR__ . '/../../..' . '/lib/public/Preview/IProvider.php', 'OCP\\Preview\\IProviderV2' => __DIR__ . '/../../..' . '/lib/public/Preview/IProviderV2.php', 'OCP\\Preview\\IVersionedPreviewFile' => __DIR__ . '/../../..' . '/lib/public/Preview/IVersionedPreviewFile.php', - 'OCP\\Push\\IManager' => __DIR__ . '/../../..' . '/lib/public/Push/IManager.php', 'OCP\\Push\\IPush' => __DIR__ . '/../../..' . '/lib/public/Push/IPush.php', 'OCP\\Push\\IPushApp' => __DIR__ . '/../../..' . '/lib/public/Push/IPushApp.php', 'OCP\\Push\\IValidateAccess' => __DIR__ . '/../../..' . '/lib/public/Push/IValidateAccess.php', @@ -624,6 +623,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\AppFramework\\Routing\\RouteConfig' => __DIR__ . '/../../..' . '/lib/private/AppFramework/Routing/RouteConfig.php', 'OC\\AppFramework\\Services\\AppConfig' => __DIR__ . '/../../..' . '/lib/private/AppFramework/Services/AppConfig.php', 'OC\\AppFramework\\Services\\InitialState' => __DIR__ . '/../../..' . '/lib/private/AppFramework/Services/InitialState.php', + 'OC\\AppFramework\\Services\\Push' => __DIR__ . '/../../..' . '/lib/private/AppFramework/Services/Push.php', 'OC\\AppFramework\\Utility\\ControllerMethodReflector' => __DIR__ . '/../../..' . '/lib/private/AppFramework/Utility/ControllerMethodReflector.php', 'OC\\AppFramework\\Utility\\SimpleContainer' => __DIR__ . '/../../..' . '/lib/private/AppFramework/Utility/SimpleContainer.php', 'OC\\AppFramework\\Utility\\TimeFactory' => __DIR__ . '/../../..' . '/lib/private/AppFramework/Utility/TimeFactory.php', @@ -1236,6 +1236,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\Preview\\WatcherConnector' => __DIR__ . '/../../..' . '/lib/private/Preview/WatcherConnector.php', 'OC\\Preview\\XBitmap' => __DIR__ . '/../../..' . '/lib/private/Preview/XBitmap.php', 'OC\\Push\\Manager' => __DIR__ . '/../../..' . '/lib/private/Push/Manager.php', + 'OC\\Push\\Push' => __DIR__ . '/../../..' . '/lib/private/Push/Push.php', 'OC\\Push\\VoidPushApp' => __DIR__ . '/../../..' . '/lib/private/Push/VoidPushApp.php', 'OC\\RedisFactory' => __DIR__ . '/../../..' . '/lib/private/RedisFactory.php', 'OC\\Remote\\Api\\ApiBase' => __DIR__ . '/../../..' . '/lib/private/Remote/Api/ApiBase.php', diff --git a/lib/private/AppFramework/Bootstrap/Coordinator.php b/lib/private/AppFramework/Bootstrap/Coordinator.php index 085e7460da6..18a099c2d02 100644 --- a/lib/private/AppFramework/Bootstrap/Coordinator.php +++ b/lib/private/AppFramework/Bootstrap/Coordinator.php @@ -25,6 +25,7 @@ declare(strict_types=1); namespace OC\AppFramework\Bootstrap; +use OC\Push\Manager as PushManager; use OC\Search\SearchComposer; use OC\Support\CrashReport\Registry; use OC_App; @@ -56,16 +57,21 @@ class Coordinator { /** @var ILogger */ private $logger; + /** @var PushManager */ + private $pushManager; + public function __construct(IServerContainer $container, Registry $registry, IEventDispatcher $eventListener, SearchComposer $searchComposer, + PushManager $pushManager, ILogger $logger) { $this->serverContainer = $container; $this->registry = $registry; $this->eventDispatcher = $eventListener; $this->searchComposer = $searchComposer; $this->logger = $logger; + $this->pushManager = $pushManager; } public function runRegistration(): void { @@ -119,6 +125,7 @@ class Coordinator { $context->delegateContainerRegistrations($apps); $context->delegateMiddlewareRegistrations($apps); $context->delegateSearchProviderRegistration($apps, $this->searchComposer); + $context->delegatePushRegistrations($this->pushManager); } public function bootApp(string $appId): void { diff --git a/lib/private/AppFramework/Bootstrap/RegistrationContext.php b/lib/private/AppFramework/Bootstrap/RegistrationContext.php index 23eee9c6e33..24e0c40d713 100644 --- a/lib/private/AppFramework/Bootstrap/RegistrationContext.php +++ b/lib/private/AppFramework/Bootstrap/RegistrationContext.php @@ -26,6 +26,7 @@ declare(strict_types=1); namespace OC\AppFramework\Bootstrap; use Closure; +use OC\Push\Manager as PushManager; use OC\Search\SearchComposer; use OC\Support\CrashReport\Registry; use OCP\AppFramework\App; @@ -60,6 +61,12 @@ class RegistrationContext { /** @var array[] */ private $searchProviders = []; + /** @var string */ + private $pushApp; + + /** @var array[] */ + private $pushAccessValidators = []; + /** @var ILogger */ private $logger; @@ -141,6 +148,17 @@ class RegistrationContext { $class ); } + + public function registerPushApp(string $service): void { + $this->context->registerPushApp($service); + } + + public function registerPushAccessValidator(string $service): void { + $this->context->registerPushAccessValidator( + $this->appId, + $service + ); + } }; } @@ -206,6 +224,17 @@ class RegistrationContext { ]; } + public function registerPushApp(string $class) { + $this->pushApp = $class; + } + + public function registerPushAccessValidator(string $appId, string $validator) { + $this->pushAccessValidators[] = [ + 'appId' => $appId, + 'validator' => $validator, + ]; + } + /** * @param App[] $apps */ @@ -362,4 +391,19 @@ class RegistrationContext { } } } + + public function delegatePushRegistrations(PushManager $manager): void { + if ($this->pushApp === null) { + $this->logger->debug('No push app to register hence skipping push registration'); + return; + } + $manager->registerPushApp($this->pushApp); + + foreach ($this->pushAccessValidators as $validator) { + $manager->registerAccessValidator( + $validator['appId'], + $validator['validator'] + ); + } + } } diff --git a/lib/private/Push/Manager.php b/lib/private/Push/Manager.php index 18c936c1865..99410d43e0e 100644 --- a/lib/private/Push/Manager.php +++ b/lib/private/Push/Manager.php @@ -32,7 +32,7 @@ use OCP\Push\IManager; use OCP\Push\IPushApp; use OCP\Push\IValidateAccess; -class Manager implements IManager, IPushApp { +class Manager implements IPushApp { /** @var array */ private $validatorClasses = []; diff --git a/lib/private/Server.php b/lib/private/Server.php index 7e5c772781b..eff190176b1 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -1363,8 +1363,6 @@ class Server extends ServerContainer implements IServerContainer { $this->registerAlias(IInitialStateService::class, InitialStateService::class); - $this->registerAlias(\OCP\Push\IManager::class, \OC\Push\Manager::class); - $this->connectDispatcher(); } diff --git a/lib/public/AppFramework/Bootstrap/IRegistrationContext.php b/lib/public/AppFramework/Bootstrap/IRegistrationContext.php index 12367e5ed05..4ac604aa6f0 100644 --- a/lib/public/AppFramework/Bootstrap/IRegistrationContext.php +++ b/lib/public/AppFramework/Bootstrap/IRegistrationContext.php @@ -28,6 +28,8 @@ namespace OCP\AppFramework\Bootstrap; use OCP\AppFramework\IAppContainer; use OCP\EventDispatcher\IEventDispatcher; use OCP\IContainer; +use OCP\Push\IPushApp; +use OCP\Push\IValidateAccess; /** * The context object passed to IBootstrap::register @@ -130,4 +132,31 @@ interface IRegistrationContext { * @since 20.0.0 */ public function registerSearchProvider(string $class): void; + + /** + * Register a push application. + * + * @param string $service + * + * @return void + * + * @see IPushApp + * + * @since 20.0.0 + */ + public function registerPushApp(string $service): void; + + + /** + * Register a Push access validator + * + * @param string $service + * + * @return void + * + * @see IValidateAccess + * + * @since 20.0.0 + */ + public function registerPushAccessValidator(string $service): void; } diff --git a/lib/public/Push/IManager.php b/lib/public/Push/IManager.php deleted file mode 100644 index 3c329d357df..00000000000 --- a/lib/public/Push/IManager.php +++ /dev/null @@ -1,50 +0,0 @@ -<?php - -declare(strict_types=1); -/** - * @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl> - * - * @author Roeland Jago Douma <roeland@famdouma.nl> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -namespace OCP\Push; - -/** - * @since 20.0.0 - */ -interface IManager { - - /** - * Register an access validator - * - * @param string $appId - * @param string $service - * - * @since 20.0.0 - */ - public function registerAccessValidator(string $appId, string $service): void; - - /** - * Regsiter the app to handle the pushing - * - * @param string $service The service that will be invoked by quering the - * container. So DI should work for this class - */ - public function registerPushApp(string $service): void; -} |