From 5dccf25e11da5a1838e56c5afd47e1068a7fc965 Mon Sep 17 00:00:00 2001 From: Andrew Summers <18727110+summersab@users.noreply.github.com> Date: Tue, 29 Aug 2023 17:12:25 -0500 Subject: [PATCH] Refactor `OC\Server::getNotificationManager` Signed-off-by: Andrew Summers <18727110+summersab@users.noreply.github.com> --- core/Application.php | 3 ++- lib/private/Repair.php | 3 ++- lib/private/User/User.php | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/core/Application.php b/core/Application.php index ca9b6ce2d8c..19bc06bd3e9 100644 --- a/core/Application.php +++ b/core/Application.php @@ -57,6 +57,7 @@ use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\Events\Node\NodeDeletedEvent; use OCP\Files\Events\Node\NodeWrittenEvent; use OCP\Files\Events\NodeRemovedFromCache; +use OCP\Notification\IManager as INotificationManager; use OCP\User\Events\BeforeUserDeletedEvent; use OCP\User\Events\UserDeletedEvent; use OCP\Util; @@ -81,7 +82,7 @@ class Application extends App { /** @var IEventDispatcher $eventDispatcher */ $eventDispatcher = $server->get(IEventDispatcher::class); - $notificationManager = $server->getNotificationManager(); + $notificationManager = $server->get(INotificationManager::class); $notificationManager->registerNotifierService(CoreNotifier::class); $notificationManager->registerNotifierService(AuthenticationNotifier::class); diff --git a/lib/private/Repair.php b/lib/private/Repair.php index 05624a2423a..2c8672fcf26 100644 --- a/lib/private/Repair.php +++ b/lib/private/Repair.php @@ -42,6 +42,7 @@ use OCP\Collaboration\Resources\IManager; use OCP\EventDispatcher\IEventDispatcher; use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; +use OCP\Notification\IManager as INotificationManager; use OC\DB\Connection; use OC\DB\ConnectionAdapter; use OC\Repair\AddBruteForceCleanupJob; @@ -198,7 +199,7 @@ class Repair implements IOutput { new AddCleanupUpdaterBackupsJob(\OC::$server->getJobList()), new CleanupCardDAVPhotoCache(\OC::$server->getConfig(), \OC::$server->getAppDataDir('dav-photocache'), \OC::$server->get(LoggerInterface::class)), new AddClenupLoginFlowV2BackgroundJob(\OC::$server->getJobList()), - new RemoveLinkShares(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig(), \OC::$server->getGroupManager(), \OC::$server->getNotificationManager(), \OCP\Server::get(ITimeFactory::class)), + new RemoveLinkShares(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig(), \OC::$server->getGroupManager(), \OC::$server->get(INotificationManager::class), \OCP\Server::get(ITimeFactory::class)), new ClearCollectionsAccessCache(\OC::$server->getConfig(), \OCP\Server::get(IManager::class)), \OCP\Server::get(ResetGeneratedAvatarFlag::class), \OCP\Server::get(EncryptionLegacyCipher::class), diff --git a/lib/private/User/User.php b/lib/private/User/User.php index d1185e17aef..3a9697bcbd4 100644 --- a/lib/private/User/User.php +++ b/lib/private/User/User.php @@ -49,6 +49,7 @@ use OCP\IImage; use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserBackend; +use OCP\Notification\IManager as INotificationManager; use OCP\User\Events\BeforePasswordUpdatedEvent; use OCP\User\Events\BeforeUserDeletedEvent; use OCP\User\Events\PasswordUpdatedEvent; @@ -297,9 +298,9 @@ class User implements IUser { $avatarManager = \OCP\Server::get(AvatarManager::class); $avatarManager->deleteUserAvatar($this->uid); - $notification = \OC::$server->getNotificationManager()->createNotification(); + $notification = \OC::$server->get(INotificationManager::class)->createNotification(); $notification->setUser($this->uid); - \OC::$server->getNotificationManager()->markProcessed($notification); + \OC::$server->get(INotificationManager::class)->markProcessed($notification); /** @var AccountManager $accountManager */ $accountManager = \OCP\Server::get(AccountManager::class);