Move over notification to new registration

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2021-04-16 12:39:08 +02:00
parent fc11617222
commit 0593b039fc
7 changed files with 12 additions and 39 deletions

View File

@ -75,19 +75,16 @@ class Application extends App implements IBootstrap {
$context->registerSearchProvider(CommentsSearchProvider::class);
$context->registerInitialStateProvider(MaxAutoCompleteResultsInitialState::class);
$context->registerNotifierService(Notifier::class);
}
public function boot(IBootContext $context): void {
$context->injectFn(Closure::fromCallable([$this, 'registerNotifier']));
$context->injectFn(Closure::fromCallable([$this, 'registerCommentsEventHandler']));
$context->getServerContainer()->get(ISearch::class)->registerProvider(LegacyProvider::class, ['apps' => ['files']]);
}
protected function registerNotifier(IServerContainer $container) {
$container->getNotificationManager()->registerNotifierService(Notifier::class);
}
protected function registerCommentsEventHandler(IServerContainer $container) {
$container->getCommentsManager()->registerEventHandler(function () {
return $this->getContainer()->query(EventHandler::class);

View File

@ -72,7 +72,6 @@ use OCP\IConfig;
use OCP\ILogger;
use OCP\IServerContainer;
use OCP\IUser;
use OCP\Notification\IManager as INotificationManager;
use Psr\Container\ContainerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
@ -117,6 +116,8 @@ class Application extends App implements IBootstrap {
$context->registerEventListener(CalendarObjectCreatedEvent::class, CalendarContactInteractionListener::class);
$context->registerEventListener(CalendarObjectUpdatedEvent::class, CalendarContactInteractionListener::class);
$context->registerEventListener(CalendarShareUpdatedEvent::class, CalendarContactInteractionListener::class);
$context->registerNotifierService(Notifier::class);
}
public function boot(IBootContext $context): void {
@ -126,7 +127,6 @@ class Application extends App implements IBootstrap {
$context->injectFn([$this, 'registerHooks']);
$context->injectFn([$this, 'registerContactsManager']);
$context->injectFn([$this, 'registerCalendarManager']);
$context->injectFn([$this, 'registerNotifier']);
$context->injectFn([$this, 'registerCalendarReminders']);
}
@ -396,10 +396,6 @@ class Application extends App implements IBootstrap {
$cm->setupCalendarProvider($calendarManager, $userId);
}
public function registerNotifier(INotificationManager $manager): void {
$manager->registerNotifierService(Notifier::class);
}
public function registerCalendarReminders(NotificationProviderManager $manager,
ILogger $logger): void {
try {

View File

@ -38,7 +38,6 @@ use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\AppFramework\IAppContainer;
use OCP\Federation\ICloudFederationProviderManager;
use OCP\Notification\IManager as INotifiactionManager;
class Application extends App implements IBootstrap {
public function __construct() {
@ -47,23 +46,19 @@ class Application extends App implements IBootstrap {
public function register(IRegistrationContext $context): void {
$context->registerEventListener(LoadAdditionalScriptsEvent::class, LoadAdditionalScriptsListener::class);
$context->registerNotifierService(Notifier::class);
}
public function boot(IBootContext $context): void {
$context->injectFn(Closure::fromCallable([$this, 'registerCloudFederationProvider']));
$context->injectFn(Closure::fromCallable([$this, 'registerNotificationManager']));
}
private function registerCloudFederationProvider(ICloudFederationProviderManager $manager,
IAppContainer $appContainer): void {
$manager->addCloudFederationProvider('file',
'Federated Files Sharing',
function () use ($appContainer) {
function () use ($appContainer): CloudFederationProviderFiles {
return $appContainer->get(CloudFederationProviderFiles::class);
});
}
private function registerNotificationManager(INotifiactionManager $manager): void {
$manager->registerNotifierService(Notifier::class);
}
}

View File

@ -61,7 +61,6 @@ use OCP\IRequest;
use OCP\IServerContainer;
use OCP\ITagManager;
use OCP\IUserSession;
use OCP\Notification\IManager;
use OCP\Share\IManager as IShareManager;
use OCP\Util;
use Psr\Container\ContainerInterface;
@ -118,12 +117,13 @@ class Application extends App implements IBootstrap {
$context->registerEventListener(LoadSidebar::class, LoadSidebarListener::class);
$context->registerSearchProvider(FilesSearchProvider::class);
$context->registerNotifierService(Notifier::class);
}
public function boot(IBootContext $context): void {
$context->injectFn(Closure::fromCallable([$this, 'registerCollaboration']));
$context->injectFn([Listener::class, 'register']);
$context->injectFn(Closure::fromCallable([$this, 'registerNotification']));
$context->injectFn(Closure::fromCallable([$this, 'registerSearchProvider']));
$this->registerTemplates();
$context->injectFn(Closure::fromCallable([$this, 'registerNavigation']));
@ -134,10 +134,6 @@ class Application extends App implements IBootstrap {
$providerManager->registerResourceProvider(ResourceProvider::class);
}
private function registerNotification(IManager $notifications): void {
$notifications->registerNotifierService(Notifier::class);
}
private function registerSearchProvider(ISearch $search): void {
$search->registerProvider(File::class, ['apps' => ['files']]);
}

View File

@ -28,7 +28,6 @@ declare(strict_types=1);
namespace OCA\TwoFactorBackupCodes\AppInfo;
use Closure;
use OCA\TwoFactorBackupCodes\Db\BackupCodeMapper;
use OCA\TwoFactorBackupCodes\Event\CodesGenerated;
use OCA\TwoFactorBackupCodes\Listener\ActivityPublisher;
@ -42,7 +41,6 @@ use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\Authentication\TwoFactorAuth\IRegistry;
use OCP\Notification\IManager;
use OCP\Util;
class Application extends App implements IBootstrap {
@ -54,12 +52,12 @@ class Application extends App implements IBootstrap {
public function register(IRegistrationContext $context): void {
$this->registerHooksAndEvents($context);
$context->registerNotifierService(Notifier::class);
}
public function boot(IBootContext $context): void {
Util::connectHook('OC_User', 'post_deleteUser', $this, 'deleteUser');
$context->injectFn(Closure::fromCallable([$this, 'registerNotification']));
}
/**
@ -73,10 +71,6 @@ class Application extends App implements IBootstrap {
$context->registerEventListener(IRegistry::EVENT_PROVIDER_DISABLED, ProviderDisabled::class);
}
private function registerNotification(IManager $manager) {
$manager->registerNotifierService(Notifier::class);
}
public function deleteUser($params) {
/** @var BackupCodeMapper $mapper */
$mapper = $this->getContainer()->query(BackupCodeMapper::class);

View File

@ -43,7 +43,6 @@ use OCP\IGroupManager;
use OCP\ILogger;
use OCP\IUser;
use OCP\IUserSession;
use OCP\Notification\IManager as INotificationManager;
use OCP\Util;
class Application extends App implements IBootstrap {
@ -52,11 +51,11 @@ class Application extends App implements IBootstrap {
}
public function register(IRegistrationContext $context): void {
$context->registerNotifierService(Notifier::class);
}
public function boot(IBootContext $context): void {
$context->injectFn(function (IConfig $config,
INotificationManager $notificationsManager,
IUserSession $userSession,
IAppManager $appManager,
IGroupManager $groupManager,
@ -67,9 +66,6 @@ class Application extends App implements IBootstrap {
return;
}
// Always register the notifier, so background jobs (without a user) can send push notifications
$notificationsManager->registerNotifierService(Notifier::class);
$user = $userSession->getUser();
if (!$user instanceof IUser) {
// Nothing to do for guests

View File

@ -81,6 +81,7 @@ class Application extends App implements IBootstrap {
}
public function register(IRegistrationContext $context): void {
$context->registerNotifierService(Notifier::class);
}
public function boot(IBootContext $context): void {
@ -96,8 +97,6 @@ class Application extends App implements IBootstrap {
) {
$configPrefixes = $helper->getServerConfigurationPrefixes(true);
if (count($configPrefixes) > 0) {
$notificationManager->registerNotifierService(Notifier::class);
$userPluginManager = $appContainer->get(UserPluginManager::class);
$groupPluginManager = $appContainer->get(GroupPluginManager::class);