2020use OCP \Notification \INotification ;
2121use OCP \Notification \INotifier ;
2222use OCP \Notification \UnknownNotificationException ;
23- use OCP \Server ;
24- use OCP \Util ;
23+ use OCP \ServerVersion ;
2524
2625class Notifier implements INotifier {
2726 /** @var string[] */
@@ -44,8 +43,10 @@ public function __construct(
4443 protected IFactory $ l10NFactory ,
4544 protected IUserSession $ userSession ,
4645 protected IGroupManager $ groupManager ,
46+ protected IAppManager $ appManager ,
47+ protected ServerVersion $ serverVersion ,
4748 ) {
48- $ this ->appVersions = $ this ->getAppVersions ();
49+ $ this ->appVersions = $ this ->appManager -> getAppInstalledVersions ();
4950 }
5051
5152 /**
@@ -144,15 +145,12 @@ public function prepare(INotification $notification, string $languageCode): INot
144145 * @param string $installedVersion
145146 * @throws AlreadyProcessedException When the update is already installed
146147 */
147- protected function updateAlreadyInstalledCheck (INotification $ notification , $ installedVersion ) {
148+ protected function updateAlreadyInstalledCheck (INotification $ notification , $ installedVersion ): void {
148149 if (version_compare ($ notification ->getObjectId (), $ installedVersion , '<= ' )) {
149150 throw new AlreadyProcessedException ();
150151 }
151152 }
152153
153- /**
154- * @return bool
155- */
156154 protected function isAdmin (): bool {
157155 $ user = $ this ->userSession ->getUser ();
158156
@@ -164,14 +162,10 @@ protected function isAdmin(): bool {
164162 }
165163
166164 protected function getCoreVersions (): string {
167- return implode ('. ' , Util::getVersion ());
168- }
169-
170- protected function getAppVersions (): array {
171- return \OC_App::getAppVersions ();
165+ return implode ('. ' , $ this ->serverVersion ->getVersion ());
172166 }
173167
174- protected function getAppInfo ($ appId , $ languageCode ) {
175- return Server:: get (IAppManager::class) ->getAppInfo ($ appId , false , $ languageCode );
168+ protected function getAppInfo (string $ appId , ? string $ languageCode ): ? array {
169+ return $ this -> appManager ->getAppInfo ($ appId , false , $ languageCode );
176170 }
177171}
0 commit comments