diff options
author | Joas Schilling <coding@schilljs.com> | 2017-01-09 11:18:59 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2017-01-09 11:18:59 +0100 |
commit | acbf0d151ff4c720532b1befc0471b18457c337b (patch) | |
tree | 61a153f1d339b164c153c00fc59f5ffce9bcddff /apps/updatenotification/lib | |
parent | e675c2a66c27605ff54a428e8f3ee76637649e25 (diff) | |
download | nextcloud-server-acbf0d151ff4c720532b1befc0471b18457c337b.tar.gz nextcloud-server-acbf0d151ff4c720532b1befc0471b18457c337b.zip |
Set the link of the notification on render instead of creation
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/updatenotification/lib')
-rw-r--r-- | apps/updatenotification/lib/Notification/BackgroundJob.php | 14 | ||||
-rw-r--r-- | apps/updatenotification/lib/Notification/Notifier.php | 3 |
2 files changed, 8 insertions, 9 deletions
diff --git a/apps/updatenotification/lib/Notification/BackgroundJob.php b/apps/updatenotification/lib/Notification/BackgroundJob.php index 7bcc0e86905..2ee3d766ea2 100644 --- a/apps/updatenotification/lib/Notification/BackgroundJob.php +++ b/apps/updatenotification/lib/Notification/BackgroundJob.php @@ -54,7 +54,7 @@ class BackgroundJob extends TimedJob { /** @var IURLGenerator */ protected $urlGenerator; - /** @var IUser[] */ + /** @var string[] */ protected $users; /** @@ -97,8 +97,7 @@ class BackgroundJob extends TimedJob { $status = $updater->check(); if (isset($status['version'])) { - $url = $this->urlGenerator->linkToRouteAbsolute('settings.AdminSettings.index') . '#updater'; - $this->createNotifications('core', $status['version'], $url, $status['versionstring']); + $this->createNotifications('core', $status['version'], $status['versionstring']); } } @@ -110,8 +109,7 @@ class BackgroundJob extends TimedJob { foreach ($apps as $app) { $update = $this->isUpdateAvailable($app); if ($update !== false) { - $url = $this->urlGenerator->linkToRouteAbsolute('settings.AppSettings.viewApps') . '#app-' . $app; - $this->createNotifications($app, $update, $url); + $this->createNotifications($app, $update); } } } @@ -121,10 +119,9 @@ class BackgroundJob extends TimedJob { * * @param string $app * @param string $version - * @param string $url * @param string $visibleVersion */ - protected function createNotifications($app, $version, $url, $visibleVersion = '') { + protected function createNotifications($app, $version, $visibleVersion = '') { $lastNotification = $this->config->getAppValue('updatenotification', $app, false); if ($lastNotification === $version) { // We already notified about this update @@ -138,8 +135,7 @@ class BackgroundJob extends TimedJob { $notification = $this->notificationManager->createNotification(); $notification->setApp('updatenotification') ->setDateTime(new \DateTime()) - ->setObject($app, $version) - ->setLink($url); + ->setObject($app, $version); if ($visibleVersion !== '') { $notification->setSubject('update_available', ['version' => $visibleVersion]); diff --git a/apps/updatenotification/lib/Notification/Notifier.php b/apps/updatenotification/lib/Notification/Notifier.php index 00cc94095ca..b23b7fe84dd 100644 --- a/apps/updatenotification/lib/Notification/Notifier.php +++ b/apps/updatenotification/lib/Notification/Notifier.php @@ -76,6 +76,7 @@ class Notifier implements INotifier { $parameters = $notification->getSubjectParameters(); $notification->setParsedSubject($l->t('Update to %1$s is available.', [$parameters['version']])); + $notification->setLink($this->url->linkToRouteAbsolute('settings.AdminSettings.index') . '#updater'); } else { $appInfo = $this->getAppInfo($notification->getObjectType()); $appName = ($appInfo === null) ? $notification->getObjectType() : $appInfo['name']; @@ -92,6 +93,8 @@ class Notifier implements INotifier { 'name' => $appName, ] ]); + + $notification->setLink($this->url->linkToRouteAbsolute('settings.AppSettings.viewApps') . '#app-' . $notification->getObjectType()); } $notification->setIcon($this->url->getAbsoluteURL($this->url->imagePath('updatenotification', 'notification.svg'))); |