diff options
author | Joas Schilling <coding@schilljs.com> | 2022-11-09 09:37:35 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2022-11-09 09:37:35 +0300 |
commit | 846552b1ad383597e5973903034028452cd231a6 (patch) | |
tree | 9fa9aa678dfa6de44d0466929101422862540e0a | |
parent | ea19c06a0bc9b4a8b0594f80641fd3185a8fa7f0 (diff) |
Add icon and file link to the notificationbugfix/210/notification-invalid-link
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r-- | img/app-dark.svg | 4 | ||||
-rw-r--r-- | lib/Notification/Notifier.php | 13 |
2 files changed, 14 insertions, 3 deletions
diff --git a/img/app-dark.svg b/img/app-dark.svg new file mode 100644 index 0000000..03d28fb --- /dev/null +++ b/img/app-dark.svg @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve"> + <path d="M13,5L12.125,14C12.064,14.549 11.552,15 11,15L5,15C4.448,15 3.936,14.549 3.875,14L3,5L13,5ZM8,6.38C6.096,6.38 4.543,7.933 4.543,9.837C4.543,11.741 6.096,13.294 8,13.294C9.904,13.294 11.457,11.741 11.457,9.837C11.457,7.933 9.904,6.38 8,6.38ZM8,7.244C9.437,7.244 10.593,8.4 10.593,9.837C10.593,11.274 9.437,12.429 8,12.429C6.563,12.429 5.407,11.274 5.407,9.837C5.407,8.4 6.563,7.244 8,7.244ZM7.809,7.647C7.665,7.65 7.549,7.768 7.549,7.912L7.181,9.831L7.181,9.836C7.102,10.163 7.326,10.269 7.576,10.421L7.579,10.422L8.874,11.104C9.156,11.321 9.482,10.898 9.2,10.681L8.432,9.84L8.432,9.837L8.083,7.914C8.083,7.764 7.96,7.643 7.809,7.647L7.809,7.647ZM9.5,1L10,2L13,2C13.554,2 14,2.446 14,3L14,4L2,4L2,3C2,2.448 2.443,2.003 3,2L6,2L6.5,1L9.5,1Z" fill="#000"/> +</svg> diff --git a/lib/Notification/Notifier.php b/lib/Notification/Notifier.php index e3e6d0c..5ce9b07 100644 --- a/lib/Notification/Notifier.php +++ b/lib/Notification/Notifier.php @@ -27,6 +27,7 @@ namespace OCA\Files_Retention\Notification; use OCA\Files_Retention\AppInfo\Application; use OCP\Files\IRootFolder; +use OCP\IURLGenerator; use OCP\L10N\IFactory; use OCP\Notification\AlreadyProcessedException; use OCP\Notification\INotification; @@ -37,10 +38,13 @@ class Notifier implements INotifier { private $l10Factory; /** @var IRootFolder */ private $rootFolder; + /** @var IURLGenerator */ + private $url; - public function __construct(IFactory $l10Factory, IRootFolder $rootFolder) { + public function __construct(IFactory $l10Factory, IRootFolder $rootFolder, IURLGenerator $url) { $this->l10Factory = $l10Factory; $this->rootFolder = $rootFolder; + $this->url = $url; } @@ -61,8 +65,9 @@ class Notifier implements INotifier { $userFolder = $this->rootFolder->getUserFolder($notification->getUser()); $subject = $notification->getSubjectParameters(); + $fileId = (int)$subject['fileId']; - $nodes = $userFolder->getById((int)$subject['fileId']); + $nodes = $userFolder->getById($fileId); if (empty($nodes)) { throw new AlreadyProcessedException(); } @@ -78,13 +83,15 @@ class Notifier implements INotifier { 'name' => $node->getName(), 'path' => $userFolder->getRelativePath($node->getPath()), 'mimetype' => $node->getMimetype(), + 'link' => $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $fileId]), ], ]) ->setParsedSubject(str_replace('{file}', $node->getName(), $l->t('{file} will be removed in 24 hours'))) ->setRichMessage( $l->t('Your systems retention rules will delete this file within 24 hours.') ) - ->setParsedMessage($l->t('Your systems retention rules will delete this file within 24 hours.')); + ->setParsedMessage($l->t('Your systems retention rules will delete this file within 24 hours.')) + ->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files_retention', 'app-dark.svg'))); return $notification; } |