fix(comments): Add an action to comment notification that dismisses it

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2026-05-04 22:21:10 +02:00 committed by backportbot[bot]
parent 2c21d7517b
commit dab6507e27
2 changed files with 18 additions and 5 deletions

View file

@ -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);

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;
@ -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;