From dab6507e27e373a24ee8c236ca76701af011ff2e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 4 May 2026 22:21:10 +0200 Subject: [PATCH] fix(comments): Add an action to comment notification that dismisses it Signed-off-by: Joas Schilling --- .../lib/Controller/NotificationsController.php | 5 ++++- apps/comments/lib/Notification/Notifier.php | 18 ++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/apps/comments/lib/Controller/NotificationsController.php b/apps/comments/lib/Controller/NotificationsController.php index 2dc94b2e663..04c34b6be70 100644 --- a/apps/comments/lib/Controller/NotificationsController.php +++ b/apps/comments/lib/Controller/NotificationsController.php @@ -79,7 +79,10 @@ class NotificationsController extends Controller { $url = $this->urlGenerator->linkToRouteAbsolute( 'files.viewcontroller.showFile', - [ 'fileid' => $comment->getObjectId() ] + [ + 'fileid' => $comment->getObjectId(), + 'opendetails' => 'true', + ] ); return new RedirectResponse($url); diff --git a/apps/comments/lib/Notification/Notifier.php b/apps/comments/lib/Notification/Notifier.php index 62562bf42aa..a15437ad8c1 100644 --- a/apps/comments/lib/Notification/Notifier.php +++ b/apps/comments/lib/Notification/Notifier.php @@ -15,6 +15,7 @@ use OCP\IURLGenerator; use OCP\IUserManager; use OCP\L10N\IFactory; use OCP\Notification\AlreadyProcessedException; +use OCP\Notification\IAction; use OCP\Notification\INotification; use OCP\Notification\INotifier; use OCP\Notification\UnknownNotificationException; @@ -116,14 +117,23 @@ class Notifier implements INotifier { 'name' => $displayName, ]; } + + $commentLink = $this->url->linkToRouteAbsolute( + 'comments.Notifications.view', + ['id' => $comment->getId()], + ); + [$message, $messageParameters] = $this->commentToRichMessage($comment); $notification->setRichSubject($subject, $subjectParameters) ->setRichMessage($message, $messageParameters) ->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/comment.svg'))) - ->setLink($this->url->linkToRouteAbsolute( - 'comments.Notifications.view', - ['id' => $comment->getId()]) - ); + ->setLink($commentLink); + + $action = $notification->createAction(); + $action->setLink($commentLink, IAction::TYPE_WEB); + $action->setPrimary(true); + $action->setParsedLabel($l->t('Go to file')); + $notification->addParsedAction($action); return $notification; break;