Skip to content

Commit 2e41ee8

Browse files
committed
fix(comments): Add an action to comment notification that dismisses it
Signed-off-by: Joas Schilling <coding@schilljs.com>
1 parent fb67d5d commit 2e41ee8

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;
@@ -118,14 +119,23 @@ public function prepare(INotification $notification, string $languageCode): INot
118119
'name' => $displayName,
119120
];
120121
}
122+
123+
$commentLink = $this->url->linkToRouteAbsolute(
124+
'comments.Notifications.view',
125+
['id' => $comment->getId()],
126+
);
127+
121128
[$message, $messageParameters] = $this->commentToRichMessage($comment);
122129
$notification->setRichSubject($subject, $subjectParameters)
123130
->setRichMessage($message, $messageParameters)
124131
->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/comment.svg')))
125-
->setLink($this->url->linkToRouteAbsolute(
126-
'comments.Notifications.view',
127-
['id' => $comment->getId()])
128-
);
132+
->setLink($commentLink);
133+
134+
$action = $notification->createAction();
135+
$action->setLink($commentLink, IAction::TYPE_WEB);
136+
$action->setPrimary(true);
137+
$action->setParsedLabel($l->t('Go to file'));
138+
$notification->addParsedAction($action);
129139

130140
return $notification;
131141
break;

0 commit comments

Comments
 (0)