Skip to content

Commit dbab25c

Browse files
Merge pull request #60174 from nextcloud/backport/60150/stable32
[stable32] fix(comments): Add an action to comment notification that dismisses it
2 parents 7626e58 + a681a83 commit dbab25c

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