diff options
Diffstat (limited to 'apps/updatenotification/lib/Notification')
-rw-r--r-- | apps/updatenotification/lib/Notification/BackgroundJob.php | 49 |
1 files changed, 38 insertions, 11 deletions
diff --git a/apps/updatenotification/lib/Notification/BackgroundJob.php b/apps/updatenotification/lib/Notification/BackgroundJob.php index f2cf7e1cd85..3a89f3813e6 100644 --- a/apps/updatenotification/lib/Notification/BackgroundJob.php +++ b/apps/updatenotification/lib/Notification/BackgroundJob.php @@ -82,15 +82,12 @@ class BackgroundJob extends TimedJob { * Check for ownCloud update */ protected function checkCoreUpdate() { - if (in_array(\OC_Util::getChannel(), ['daily', 'git'])) { + if (in_array($this->getChannel(), ['daily', 'git'])) { // "These aren't the update channels you're looking for." - Ben Obi-Wan Kenobi return; } - $updater = new VersionCheck( - $this->client, - $this->config - ); + $updater = $this->createVersionCheck(); $status = $updater->check(); if (isset($status['version'])) { @@ -104,7 +101,7 @@ class BackgroundJob extends TimedJob { protected function checkAppUpdates() { $apps = $this->appManager->getInstalledApps(); foreach ($apps as $app) { - $update = Installer::isUpdateAvailable($app); + $update = $this->isUpdateAvailable($app); if ($update !== false) { $this->createNotifications($app, $update); } @@ -134,8 +131,8 @@ class BackgroundJob extends TimedJob { ->setObject($app, $version) ->setSubject('update_available'); - foreach ($this->getUsersToNotify() as $user) { - $notification->setUser($user->getUID()); + foreach ($this->getUsersToNotify() as $uid) { + $notification->setUser($uid); $this->notificationManager->notify($notification); } @@ -143,21 +140,26 @@ class BackgroundJob extends TimedJob { } /** - * @return \OCP\IUser[] + * @return string[] */ protected function getUsersToNotify() { if ($this->users !== null) { return $this->users; } - $notifyGroups = json_decode($this->config->getAppValue('updatenotification', 'notify_groups', '["admin"]')); + $notifyGroups = json_decode($this->config->getAppValue('updatenotification', 'notify_groups', '["admin"]'), true); + $this->users = []; foreach ($notifyGroups as $group) { $groupToNotify = $this->groupManager->get($group); if ($groupToNotify instanceof IGroup) { - $this->users = array_merge($this->users, $groupToNotify->getUsers()); + foreach ($groupToNotify->getUsers() as $user) { + $this->users[$user->getUID()] = true; + } } } + $this->users = array_keys($this->users); + return $this->users; } @@ -173,4 +175,29 @@ class BackgroundJob extends TimedJob { ->setObject($app, $version); $this->notificationManager->markProcessed($notification); } + + /** + * @return VersionCheck + */ + protected function createVersionCheck() { + return new VersionCheck( + $this->client, + $this->config + ); + } + + /** + * @return string + */ + protected function getChannel() { + return \OC_Util::getChannel(); + } + + /** + * @param string $app + * @return string|false + */ + protected function isUpdateAvailable($app) { + return Installer::isUpdateAvailable($app); + } } |