Skip to content
Prev Previous commit
Next Next commit
Fix new core notifier
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Jul 15, 2019
commit 64f67818bcc6cc61cc49b1a7c032f3db85b73c91
20 changes: 2 additions & 18 deletions core/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,8 @@ public function __construct() {
$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) {
Expand Down
23 changes: 21 additions & 2 deletions core/Notification/RemoveLinkSharesNotifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,27 @@ public function __construct(IFactory $factory) {
$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();
}
Expand All @@ -51,5 +71,4 @@ public function prepare(INotification $notification, $languageCode): INotificati

throw new \InvalidArgumentException('Invalid subject');
}

}
21 changes: 20 additions & 1 deletion lib/private/Authentication/Notifications/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct(IL10nFactory $l10nFactory) {
/**
* @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();
Expand Down Expand Up @@ -74,4 +74,23 @@ public function prepare(INotification $notification, $languageCode) {
}
}

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