refactor: use `APP_NAME` where possible

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
pull/52669/head
Ferdinand Thiessen 2025-05-06 19:38:52 +07:00
parent 2f1c74d43f
commit 1a8a6bea97
No known key found for this signature in database
GPG Key ID: 45FAE7268762B400
4 changed files with 17 additions and 14 deletions

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

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

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

@ -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;