Skip to content

Commit dab6507

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 2c21d75 commit dab6507

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
@@ -79,7 +79,10 @@ public function view(string $id): RedirectResponse|NotFoundResponse {
7979

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

8588
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;
@@ -116,14 +117,23 @@ public function prepare(INotification $notification, string $languageCode): INot
116117
'name' => $displayName,
117118
];
118119
}
120+
121+
$commentLink = $this->url->linkToRouteAbsolute(
122+
'comments.Notifications.view',
123+
['id' => $comment->getId()],
124+
);
125+
119126
[$message, $messageParameters] = $this->commentToRichMessage($comment);
120127
$notification->setRichSubject($subject, $subjectParameters)
121128
->setRichMessage($message, $messageParameters)
122129
->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/comment.svg')))
123-
->setLink($this->url->linkToRouteAbsolute(
124-
'comments.Notifications.view',
125-
['id' => $comment->getId()])
126-
);
130+
->setLink($commentLink);
131+
132+
$action = $notification->createAction();
133+
$action->setLink($commentLink, IAction::TYPE_WEB);
134+
$action->setPrimary(true);
135+
$action->setParsedLabel($l->t('Go to file'));
136+
$notification->addParsedAction($action);
127137

128138
return $notification;
129139
break;

0 commit comments

Comments
 (0)