From 1bcac9d6abc592ea7b49eac13abdcee36b25cb52 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 16 Jul 2019 17:00:40 +0200 Subject: [PATCH 1/3] Adjust notifier to Nextcloud 17 Signed-off-by: Joas Schilling --- lib/AppInfo/Application.php | 14 +++----------- lib/Notification/Notifier.php | 22 +++++++++++++++++++++- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 97cf362..e5d89d0 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -2,7 +2,7 @@ declare(strict_types=1); /** * @copyright Copyright (c) 2018 John Molakvoæ - * + * * @author John Molakvoæ * * @license GNU AGPL version 3 or any later version @@ -33,7 +33,7 @@ class Application extends App { /** @var string */ protected $appName = 'preferred_providers'; - + public function __construct() { parent::__construct($this->appName); } @@ -45,14 +45,6 @@ public function register() { protected function registerNotifier(IServerContainer $server) { $manager = $server->getNotificationManager(); - $manager->registerNotifier(function() use ($server) { - return $server->query(Notifier::class); - }, function() use ($server) { - $l = $server->getL10N($this->appName); - return [ - 'id' => $this->appName, - 'name' => $l->t('Simple signup'), - ]; - }); + $manager->registerNotifierService(Notifier::class); } } diff --git a/lib/Notification/Notifier.php b/lib/Notification/Notifier.php index 1099135..39e6927 100644 --- a/lib/Notification/Notifier.php +++ b/lib/Notification/Notifier.php @@ -54,13 +54,33 @@ public function __construct(string $appName, $this->urlGenerator = $urlGenerator; } + /** + * Identifier of the notifier, only use [a-z0-9_] + * + * @return string + * @since 17.0.0 + */ + public function getID(): string { + return $this->appName; + } + + /** + * Human readable name describing the notifier + * + * @return string + * @since 17.0.0 + */ + public function getName(): string { + return $this->l10nFactory->get($this->appName)->t('Simple signup'); + } + /** * @param INotification $notification * @param string $languageCode The code of the language that should be used to prepare the notification * @return INotification * @throws \InvalidArgumentException When the notification was not prepared by a notifier */ - public function prepare(INotification $notification, $languageCode): INotification { + public function prepare(INotification $notification, string $languageCode): INotification { if ($notification->getApp() !== $this->appName) { throw new \InvalidArgumentException('Incorrect app'); } From c258f6611b736470b2a8432e88731ac510f63d26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6?= Date: Sun, 28 Jul 2019 16:12:11 +0200 Subject: [PATCH 2/3] Update info.xml --- appinfo/info.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/appinfo/info.xml b/appinfo/info.xml index 35ffaf7..69e1277 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -12,14 +12,14 @@ files https://github.com/nextcloud/preferred_providers - + OCA\Preferred_Providers\Settings\Admin - OCA\Preferred_Providers\Settings\Section + OCA\Preferred_Providers\Settings\Section - OCA\Preferred_Providers\BackgroundJob\NotifyUnsetPassword - OCA\Preferred_Providers\BackgroundJob\ExpireUnverifiedAccounts + OCA\Preferred_Providers\BackgroundJob\NotifyUnsetPassword + OCA\Preferred_Providers\BackgroundJob\ExpireUnverifiedAccounts From d5a5e4979260951809fd65d0a137b20d75f758a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6?= Date: Fri, 23 Aug 2019 11:52:39 +0200 Subject: [PATCH 3/3] Fix max version --- appinfo/info.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appinfo/info.xml b/appinfo/info.xml index 69e1277..4fe2ad0 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -12,7 +12,7 @@ files https://github.com/nextcloud/preferred_providers - + OCA\Preferred_Providers\Settings\Admin