aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2025-05-06 19:38:52 +0200
committerFerdinand Thiessen <opensource@fthiessen.de>2025-05-13 09:49:28 +0200
commit1a8a6bea97778aad843984a608fd65b1ce8f9675 (patch)
treef8b5bae8e3cdb5853374e89868cb0a2bca3ce6b8
parent2f1c74d43f1df892d3b44802944c8f38d719b2d5 (diff)
downloadnextcloud-server-1a8a6bea97778aad843984a608fd65b1ce8f9675.tar.gz
nextcloud-server-1a8a6bea97778aad843984a608fd65b1ce8f9675.zip
refactor: use `APP_NAME` where possible
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
-rw-r--r--apps/updatenotification/lib/AppInfo/Application.php2
-rw-r--r--apps/updatenotification/lib/BackgroundJob/UpdateAvailableNotifications.php15
-rw-r--r--apps/updatenotification/lib/Notification/Notifier.php13
-rw-r--r--apps/updatenotification/lib/Settings/Admin.php1
4 files changed, 17 insertions, 14 deletions
diff --git a/apps/updatenotification/lib/AppInfo/Application.php b/apps/updatenotification/lib/AppInfo/Application.php
index d34429e9e73..56012667bb4 100644
--- a/apps/updatenotification/lib/AppInfo/Application.php
+++ b/apps/updatenotification/lib/AppInfo/Application.php
@@ -73,7 +73,7 @@ class Application extends App implements IBootstrap {
}
if ($updateChecker->getUpdateState() !== []) {
- Util::addScript('updatenotification', 'update-notification-legacy');
+ Util::addScript(self::APP_NAME, 'update-notification-legacy');
$updateChecker->setInitialState();
}
}
diff --git a/apps/updatenotification/lib/BackgroundJob/UpdateAvailableNotifications.php b/apps/updatenotification/lib/BackgroundJob/UpdateAvailableNotifications.php
index 29bd5cb1426..917297bacb7 100644
--- a/apps/updatenotification/lib/BackgroundJob/UpdateAvailableNotifications.php
+++ b/apps/updatenotification/lib/BackgroundJob/UpdateAvailableNotifications.php
@@ -10,6 +10,7 @@ namespace OCA\UpdateNotification\BackgroundJob;
use OC\Installer;
use OC\Updater\VersionCheck;
+use OCA\UpdateNotification\AppInfo\Application;
use OCP\App\IAppManager;
use OCP\AppFramework\Services\IAppConfig;
use OCP\AppFramework\Utility\ITimeFactory;
@@ -104,9 +105,9 @@ class UpdateAvailableNotifications extends TimedJob {
$notification = $this->notificationManager->createNotification();
try {
- $notification->setApp('updatenotification')
+ $notification->setApp(Application::APP_NAME)
->setDateTime(new \DateTime())
- ->setObject('updatenotification', 'error')
+ ->setObject(Application::APP_NAME, 'error')
->setSubject('connection_error', ['days' => $numDays]);
foreach ($this->getUsersToNotify() as $uid) {
@@ -124,9 +125,9 @@ class UpdateAvailableNotifications extends TimedJob {
protected function clearErrorNotifications() {
$notification = $this->notificationManager->createNotification();
try {
- $notification->setApp('updatenotification')
+ $notification->setApp(Application::APP_NAME)
->setSubject('connection_error')
- ->setObject('updatenotification', 'error');
+ ->setObject(Application::APP_NAME, 'error');
} catch (\InvalidArgumentException $e) {
return;
}
@@ -167,7 +168,7 @@ class UpdateAvailableNotifications extends TimedJob {
$notification = $this->notificationManager->createNotification();
try {
- $notification->setApp('updatenotification')
+ $notification->setApp(Application::APP_NAME)
->setDateTime(new \DateTime())
->setObject($app, $version);
@@ -220,9 +221,9 @@ class UpdateAvailableNotifications extends TimedJob {
protected function deleteOutdatedNotifications($app, $version) {
$notification = $this->notificationManager->createNotification();
try {
- $notification->setApp('updatenotification')
+ $notification->setApp(Application::APP_NAME)
->setObject($app, $version);
- } catch (\InvalidArgumentException $e) {
+ } catch (\InvalidArgumentException) {
return;
}
$this->notificationManager->markProcessed($notification);
diff --git a/apps/updatenotification/lib/Notification/Notifier.php b/apps/updatenotification/lib/Notification/Notifier.php
index 8ce6bfc2d3d..ce56e875163 100644
--- a/apps/updatenotification/lib/Notification/Notifier.php
+++ b/apps/updatenotification/lib/Notification/Notifier.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
*/
namespace OCA\UpdateNotification\Notification;
+use OCA\UpdateNotification\AppInfo\Application;
use OCP\App\IAppManager;
use OCP\IConfig;
use OCP\IGroupManager;
@@ -56,7 +57,7 @@ class Notifier implements INotifier {
* @since 17.0.0
*/
public function getID(): string {
- return 'updatenotification';
+ return Application::APP_NAME;
}
/**
@@ -66,7 +67,7 @@ class Notifier implements INotifier {
* @since 17.0.0
*/
public function getName(): string {
- return $this->l10NFactory->get('updatenotification')->t('Update notifications');
+ return $this->l10NFactory->get(Application::APP_NAME)->t('Update notifications');
}
/**
@@ -78,7 +79,7 @@ class Notifier implements INotifier {
* @since 9.0.0
*/
public function prepare(INotification $notification, string $languageCode): INotification {
- if ($notification->getApp() !== 'updatenotification') {
+ if ($notification->getApp() !== Application::APP_NAME) {
throw new UnknownNotificationException('Unknown app id');
}
@@ -86,9 +87,9 @@ class Notifier implements INotifier {
throw new UnknownNotificationException('Unknown subject');
}
- $l = $this->l10NFactory->get('updatenotification', $languageCode);
+ $l = $this->l10NFactory->get(Application::APP_NAME, $languageCode);
if ($notification->getSubject() === 'connection_error') {
- $errors = (int)$this->config->getAppValue('updatenotification', 'update_check_errors', '0');
+ $errors = $this->appConfig->getValueInt(Application::APP_NAME, 'update_check_errors', 0);
if ($errors === 0) {
throw new AlreadyProcessedException();
}
@@ -133,7 +134,7 @@ class Notifier implements INotifier {
}
}
- $notification->setIcon($this->url->getAbsoluteURL($this->url->imagePath('updatenotification', 'notification.svg')));
+ $notification->setIcon($this->url->getAbsoluteURL($this->url->imagePath(Application::APP_NAME, 'notification.svg')));
return $notification;
}
diff --git a/apps/updatenotification/lib/Settings/Admin.php b/apps/updatenotification/lib/Settings/Admin.php
index dfd4de4180f..f2115bd42ee 100644
--- a/apps/updatenotification/lib/Settings/Admin.php
+++ b/apps/updatenotification/lib/Settings/Admin.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
*/
namespace OCA\UpdateNotification\Settings;
+use OCA\UpdateNotification\AppInfo\Application;
use OCA\UpdateNotification\UpdateChecker;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Services\IInitialState;