From 19f8d27f48fe1e15c6d90846fbc2f08bd40a20a7 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Fri, 4 Apr 2025 16:02:00 +0200 Subject: [PATCH 1/4] fix(files_reminders): add missing import - Resolves https://github.com/nextcloud/server/issues/51943 Signed-off-by: Ferdinand Thiessen --- apps/files_reminders/composer/composer/autoload_classmap.php | 1 + apps/files_reminders/composer/composer/autoload_static.php | 1 + apps/files_reminders/lib/AppInfo/Application.php | 1 + apps/files_reminders/lib/SetupChecks/NeedNotificationsApp.php | 2 +- 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/files_reminders/composer/composer/autoload_classmap.php b/apps/files_reminders/composer/composer/autoload_classmap.php index 8d6284d3b5f5f..cf2dd9429d6a0 100644 --- a/apps/files_reminders/composer/composer/autoload_classmap.php +++ b/apps/files_reminders/composer/composer/autoload_classmap.php @@ -25,4 +25,5 @@ 'OCA\\FilesReminders\\Model\\RichReminder' => $baseDir . '/../lib/Model/RichReminder.php', 'OCA\\FilesReminders\\Notification\\Notifier' => $baseDir . '/../lib/Notification/Notifier.php', 'OCA\\FilesReminders\\Service\\ReminderService' => $baseDir . '/../lib/Service/ReminderService.php', + 'OCA\\FilesReminders\\SetupChecks\\NeedNotificationsApp' => $baseDir . '/../lib/SetupChecks/NeedNotificationsApp.php', ); diff --git a/apps/files_reminders/composer/composer/autoload_static.php b/apps/files_reminders/composer/composer/autoload_static.php index f1d8b8c8d0b35..076cfb615d50e 100644 --- a/apps/files_reminders/composer/composer/autoload_static.php +++ b/apps/files_reminders/composer/composer/autoload_static.php @@ -40,6 +40,7 @@ class ComposerStaticInitFilesReminders 'OCA\\FilesReminders\\Model\\RichReminder' => __DIR__ . '/..' . '/../lib/Model/RichReminder.php', 'OCA\\FilesReminders\\Notification\\Notifier' => __DIR__ . '/..' . '/../lib/Notification/Notifier.php', 'OCA\\FilesReminders\\Service\\ReminderService' => __DIR__ . '/..' . '/../lib/Service/ReminderService.php', + 'OCA\\FilesReminders\\SetupChecks\\NeedNotificationsApp' => __DIR__ . '/..' . '/../lib/SetupChecks/NeedNotificationsApp.php', ); public static function getInitializer(ClassLoader $loader) diff --git a/apps/files_reminders/lib/AppInfo/Application.php b/apps/files_reminders/lib/AppInfo/Application.php index 0ad503264d24a..2776e9db0b11e 100644 --- a/apps/files_reminders/lib/AppInfo/Application.php +++ b/apps/files_reminders/lib/AppInfo/Application.php @@ -16,6 +16,7 @@ use OCA\FilesReminders\Listener\SabrePluginAddListener; use OCA\FilesReminders\Listener\UserDeletedListener; use OCA\FilesReminders\Notification\Notifier; +use OCA\FilesReminders\SetupChecks\NeedNotificationsApp; use OCP\AppFramework\App; use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; diff --git a/apps/files_reminders/lib/SetupChecks/NeedNotificationsApp.php b/apps/files_reminders/lib/SetupChecks/NeedNotificationsApp.php index 2fc80094152be..0ad3150b8152c 100644 --- a/apps/files_reminders/lib/SetupChecks/NeedNotificationsApp.php +++ b/apps/files_reminders/lib/SetupChecks/NeedNotificationsApp.php @@ -7,7 +7,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace OCA\DAV\SetupChecks; +namespace OCA\FilesReminders\SetupChecks; use OCP\App\IAppManager; use OCP\SetupCheck\ISetupCheck; From e60d69352b8b0ce6fa0ae480f98f06aa08105066 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Fri, 4 Apr 2025 16:12:45 +0200 Subject: [PATCH 2/4] fix(files_reminders): add l10n to constructor of setup check Signed-off-by: Ferdinand Thiessen --- apps/files_reminders/lib/SetupChecks/NeedNotificationsApp.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/files_reminders/lib/SetupChecks/NeedNotificationsApp.php b/apps/files_reminders/lib/SetupChecks/NeedNotificationsApp.php index 0ad3150b8152c..1dc7d652c6731 100644 --- a/apps/files_reminders/lib/SetupChecks/NeedNotificationsApp.php +++ b/apps/files_reminders/lib/SetupChecks/NeedNotificationsApp.php @@ -10,12 +10,14 @@ namespace OCA\FilesReminders\SetupChecks; use OCP\App\IAppManager; +use OCP\IL10N; use OCP\SetupCheck\ISetupCheck; use OCP\SetupCheck\SetupResult; class NeedNotificationsApp implements ISetupCheck { public function __construct( private IAppManager $appManager, + private IL10N $l10n, ) { } @@ -28,7 +30,7 @@ public function getCategory(): string { } public function run(): SetupResult { - if ($this->appManager->isInstalled('notifications')) { + if ($this->appManager->isEnabledForAnyone('notifications')) { return SetupResult::success($this->l10n->t('This files_reminder can work properly.')); } else { return SetupResult::warning($this->l10n->t('The files_reminder app needs the notification app to work properly. You should either enable notifications or disable files_reminder.')); From 1ab680ae69d0e281c03f7c0301e2cbf2b809f0ac Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Fri, 4 Apr 2025 16:30:56 +0200 Subject: [PATCH 3/4] chore: lint files_reminders using psalm Signed-off-by: Ferdinand Thiessen --- apps/files_reminders/lib/Notification/Notifier.php | 2 +- build/psalm-baseline.xml | 6 ++++++ psalm.xml | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/files_reminders/lib/Notification/Notifier.php b/apps/files_reminders/lib/Notification/Notifier.php index 000b04119cd01..fd858a01cc5f4 100644 --- a/apps/files_reminders/lib/Notification/Notifier.php +++ b/apps/files_reminders/lib/Notification/Notifier.php @@ -75,7 +75,7 @@ public function prepare(INotification $notification, string $languageCode): INot [ 'name' => [ 'type' => 'highlight', - 'id' => $node->getId(), + 'id' => (string)$node->getId(), 'name' => $node->getName(), ], ], diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml index 4b4f232fad6d6..e05423a3fbfe7 100644 --- a/build/psalm-baseline.xml +++ b/build/psalm-baseline.xml @@ -872,6 +872,12 @@ + + + + + + diff --git a/psalm.xml b/psalm.xml index bd2b9675743ff..276760a1fef23 100644 --- a/psalm.xml +++ b/psalm.xml @@ -30,6 +30,7 @@ + From 5486d0a1b1461a673432016cb100e56b20bcc911 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Mon, 7 Apr 2025 11:56:56 +0200 Subject: [PATCH 4/4] chore: adjust syntax for app manager Signed-off-by: Ferdinand Thiessen --- apps/files_reminders/lib/SetupChecks/NeedNotificationsApp.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/files_reminders/lib/SetupChecks/NeedNotificationsApp.php b/apps/files_reminders/lib/SetupChecks/NeedNotificationsApp.php index 1dc7d652c6731..ab37aea8e6049 100644 --- a/apps/files_reminders/lib/SetupChecks/NeedNotificationsApp.php +++ b/apps/files_reminders/lib/SetupChecks/NeedNotificationsApp.php @@ -30,7 +30,7 @@ public function getCategory(): string { } public function run(): SetupResult { - if ($this->appManager->isEnabledForAnyone('notifications')) { + if ($this->appManager->isInstalled('notifications')) { return SetupResult::success($this->l10n->t('This files_reminder can work properly.')); } else { return SetupResult::warning($this->l10n->t('The files_reminder app needs the notification app to work properly. You should either enable notifications or disable files_reminder.'));