Преглед изворни кода

Fix new core notifier

Signed-off-by: Joas Schilling <coding@schilljs.com>
tags/v17.0.0beta1
Joas Schilling пре 5 година
родитељ
комит
64f67818bc
No account linked to committer's email address

+ 2
- 18
core/Application.php Прегледај датотеку

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

+ 21
- 2
core/Notification/RemoveLinkSharesNotifier.php Прегледај датотеку

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

}

+ 20
- 1
lib/private/Authentication/Notifications/Notifier.php Прегледај датотеку

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

Loading…
Откажи
Сачувај