Skip to content

Commit a24ef51

Browse files
nickvergessenbackportbot[bot]
authored andcommitted
fix(comments): Add an action to comment notification that dismisses it
Signed-off-by: Joas Schilling <coding@schilljs.com>
1 parent 0b87ddd commit a24ef51

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

apps/comments/lib/Controller/NotificationsController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ public function view(string $id): RedirectResponse|NotFoundResponse {
8080

8181
$url = $this->urlGenerator->linkToRouteAbsolute(
8282
'files.viewcontroller.showFile',
83-
[ 'fileid' => $comment->getObjectId() ]
83+
[
84+
'fileid' => $comment->getObjectId(),
85+
'opendetails' => 'true',
86+
]
8487
);
8588

8689
return new RedirectResponse($url);

apps/comments/lib/Notification/Notifier.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use OCP\IUserManager;
1616
use OCP\L10N\IFactory;
1717
use OCP\Notification\AlreadyProcessedException;
18+
use OCP\Notification\IAction;
1819
use OCP\Notification\INotification;
1920
use OCP\Notification\INotifier;
2021
use OCP\Notification\UnknownNotificationException;
@@ -115,14 +116,23 @@ public function prepare(INotification $notification, string $languageCode): INot
115116
'name' => $displayName,
116117
];
117118
}
119+
120+
$commentLink = $this->url->linkToRouteAbsolute(
121+
'comments.Notifications.view',
122+
['id' => $comment->getId()],
123+
);
124+
118125
[$message, $messageParameters] = $this->commentToRichMessage($comment);
119126
$notification->setRichSubject($subject, $subjectParameters)
120127
->setRichMessage($message, $messageParameters)
121128
->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/comment.svg')))
122-
->setLink($this->url->linkToRouteAbsolute(
123-
'comments.Notifications.view',
124-
['id' => $comment->getId()])
125-
);
129+
->setLink($commentLink);
130+
131+
$action = $notification->createAction();
132+
$action->setLink($commentLink, IAction::TYPE_WEB);
133+
$action->setPrimary(true);
134+
$action->setParsedLabel($l->t('Go to file'));
135+
$notification->addParsedAction($action);
126136

127137
return $notification;
128138
break;

0 commit comments

Comments
 (0)