Merge pull request #60175 from nextcloud/backport/60150/stable33

[stable33] fix(comments): Add an action to comment notification that dismisses it
This commit is contained in:
Joas Schilling 2026-05-07 10:01:50 +02:00 committed by GitHub
commit 25c30c1b9c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 5 deletions

View file

@ -80,7 +80,10 @@ class NotificationsController extends Controller {
$url = $this->urlGenerator->linkToRouteAbsolute(
'files.viewcontroller.showFile',
[ 'fileid' => $comment->getObjectId() ]
[
'fileid' => $comment->getObjectId(),
'opendetails' => 'true',
]
);
return new RedirectResponse($url);

View file

@ -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;
@ -115,14 +116,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;