2626use OC \Authentication \Token \IProvider ;
2727use OCA \Notifications \App ;
2828use OCA \Notifications \Capabilities ;
29+ use OCA \Notifications \Listener \BeforeTemplateRenderedListener ;
2930use OCA \Notifications \Listener \UserDeletedListener ;
3031use OCA \Notifications \Notifier \AdminNotifications ;
3132use OCP \AppFramework \Bootstrap \IBootContext ;
3233use OCP \AppFramework \Bootstrap \IBootstrap ;
3334use OCP \AppFramework \Bootstrap \IRegistrationContext ;
35+ use OCP \AppFramework \Http \Events \BeforeTemplateRenderedEvent ;
3436use OCP \AppFramework \IAppContainer ;
35- use OCP \IRequest ;
36- use OCP \IUserSession ;
3737use OCP \Notification \IManager ;
3838use OCP \User \Events \UserDeletedEvent ;
39- use OCP \Util ;
4039
4140class Application extends \OCP \AppFramework \App implements IBootstrap {
4241 public const APP_ID = 'notifications ' ;
@@ -52,27 +51,18 @@ public function register(IRegistrationContext $context): void {
5251 return $ c ->getServer ()->get (IProvider::class);
5352 });
5453
54+ $ context ->registerNotifierService (AdminNotifications::class);
55+
5556 $ context ->registerEventListener (UserDeletedEvent::class, UserDeletedListener::class);
57+ $ context ->registerEventListener (BeforeTemplateRenderedEvent::class, BeforeTemplateRenderedListener::class);
5658 }
5759
5860 public function boot (IBootContext $ context ): void {
5961 $ context ->injectFn (\Closure::fromCallable ([$ this , 'registerAppAndNotifier ' ]));
6062 }
6163
62- public function registerAppAndNotifier (IManager $ notificationManager, IRequest $ request , IUserSession $ userSession ): void {
64+ public function registerAppAndNotifier (IManager $ notificationManager ): void {
6365 // notification app
6466 $ notificationManager ->registerApp (App::class);
65-
66- // admin notifications
67- $ notificationManager ->registerNotifierService (AdminNotifications::class);
68-
69- // User interface
70- if ($ userSession ->getUser () !== null
71- && strpos ($ request ->getPathInfo (), '/s/ ' ) !== 0
72- && strpos ($ request ->getPathInfo (), '/login/ ' ) !== 0
73- && substr ($ request ->getScriptName (), 0 - \strlen ('/index.php ' )) === '/index.php ' ) {
74- Util::addScript ('notifications ' , 'notifications-main ' );
75- Util::addStyle ('notifications ' , 'styles ' );
76- }
7767 }
7868}
0 commit comments