]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix new core notifier
authorJoas Schilling <coding@schilljs.com>
Tue, 30 Apr 2019 10:08:22 +0000 (12:08 +0200)
committerJoas Schilling <coding@schilljs.com>
Mon, 15 Jul 2019 13:14:58 +0000 (15:14 +0200)
Signed-off-by: Joas Schilling <coding@schilljs.com>
core/Application.php
core/Notification/RemoveLinkSharesNotifier.php
lib/private/Authentication/Notifications/Notifier.php

index 9655a8e1a47d1b176afe7dd6213b30d05aa7422d..3a212f8547282775f579fac9b38ac965057d0d7b 100644 (file)
@@ -65,24 +65,8 @@ class Application extends App {
                $eventDispatcher = $server->query(IEventDispatcher::class);
 
                $notificationManager = $server->getNotificationManager();
-               $notificationManager->registerNotifier(function () use ($server) {
-                       return new RemoveLinkSharesNotifier(
-                               $server->getL10NFactory()
-                       );
-               }, function () {
-                       return [
-                               'id' => 'core',
-                               'name' => 'core',
-                       ];
-               });
-               $notificationManager->registerNotifier(function () use ($server) {
-                       return $server->query(AuthenticationNotifier::class);
-               }, function () {
-                       return [
-                               'id' => 'auth',
-                               'name' => 'authentication notifier',
-                       ];
-               });
+               $notificationManager->registerNotifier(RemoveLinkSharesNotifier::class);
+               $notificationManager->registerNotifier(AuthenticationNotifier::class);
 
                $eventDispatcher->addListener(IDBConnection::CHECK_MISSING_INDEXES_EVENT,
                        function (GenericEvent $event) use ($container) {
index b77846c847e325a185dac3629200e9cd9d670aae..b2e73aee237d6364b39f9f2c48512f37779bebc7 100644 (file)
@@ -36,7 +36,27 @@ class RemoveLinkSharesNotifier implements INotifier {
                $this->l10nFactory = $factory;
        }
 
-       public function prepare(INotification $notification, $languageCode): INotification {
+       /**
+        * Identifier of the notifier, only use [a-z0-9_]
+        *
+        * @return string
+        * @since 17.0.0
+        */
+       public function getID(): string {
+               return 'core';
+       }
+
+       /**
+        * Human readable name describing the notifier
+        *
+        * @return string
+        * @since 17.0.0
+        */
+       public function getName(): string {
+               return $this->l10nFactory->get('core')->t('Nextcloud Server');
+       }
+
+       public function prepare(INotification $notification, string $languageCode): INotification {
                if($notification->getApp() !== 'core') {
                        throw new \InvalidArgumentException();
                }
@@ -51,5 +71,4 @@ class RemoveLinkSharesNotifier implements INotifier {
 
                throw new \InvalidArgumentException('Invalid subject');
        }
-
 }
index 0aafc115b22e76b3181df8d81412f69e4430177d..f76bb077a3cd914702cd1b66ab7d42bd922383fd 100644 (file)
@@ -42,7 +42,7 @@ class Notifier implements INotifier {
        /**
         * @inheritDoc
         */
-       public function prepare(INotification $notification, $languageCode) {
+       public function prepare(INotification $notification, string $languageCode): INotification {
                if ($notification->getApp() !== 'auth') {
                        // Not my app => throw
                        throw new InvalidArgumentException();
@@ -74,4 +74,23 @@ class Notifier implements INotifier {
                }
        }
 
+       /**
+        * Identifier of the notifier, only use [a-z0-9_]
+        *
+        * @return string
+        * @since 17.0.0
+        */
+       public function getID(): string {
+               return 'auth';
+       }
+
+       /**
+        * Human readable name describing the notifier
+        *
+        * @return string
+        * @since 17.0.0
+        */
+       public function getName(): string {
+               return $this->factory->get('lib')->t('Authentication');
+       }
 }