Fix new core notifier

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2019-04-30 12:08:22 +02:00
parent 865c12aa0e
commit 64f67818bc
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA
3 changed files with 43 additions and 21 deletions

View 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) {

View 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');
}
}

View 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');
}
}