Skip to content

Commit

Permalink
Merge pull request #1759 from nextcloud/fix/notification-action-url
Browse files Browse the repository at this point in the history
fix(notification): Make sure the action URL is an absolute URL
  • Loading branch information
kesselb authored Nov 19, 2024
2 parents 72d9940 + 0847ec9 commit 3fb88af
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions lib/Service/NotificationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ public function notificationInvited(Member $member): void {
);

$declineAction = $notification->createAction();
$declineUrl = $this->linkToOCS('circles.Local.circleLeave', ['circleId' => $member->getCircleId()]);
$declineUrl = $this->urlGenerator->linkToOCSRouteAbsolute('circles.Local.circleLeave', ['circleId' => $member->getCircleId()]);
$declineAction->setLabel('refuse')
->setLink($declineUrl, 'PUT');
$notification->addAction($declineAction);

$acceptAction = $notification->createAction();
$acceptUrl = $this->linkToOCS('circles.Local.circleJoin', ['circleId' => $member->getCircleId()]);
$acceptUrl = $this->urlGenerator->linkToOCSRouteAbsolute('circles.Local.circleJoin', ['circleId' => $member->getCircleId()]);
$acceptAction->setLabel('accept')
->setLink($acceptUrl, 'PUT');
$notification->addAction($acceptAction);
Expand Down Expand Up @@ -126,7 +126,7 @@ public function notificationRequested(Member $member): void {
);

$declineAction = $notification->createAction();
$declineUrl = $this->linkToOCS(
$declineUrl = $this->urlGenerator->linkToOCSRouteAbsolute(
'circles.Local.memberRemove',
[
'circleId' => $member->getCircleId(),
Expand All @@ -138,7 +138,7 @@ public function notificationRequested(Member $member): void {
$notification->addAction($declineAction);

$acceptAction = $notification->createAction();
$acceptUrl = $this->linkToOCS(
$acceptUrl = $this->urlGenerator->linkToOCSRouteAbsolute(
'circles.Local.memberConfirm',
[
'circleId' => $member->getCircleId(),
Expand Down Expand Up @@ -193,19 +193,6 @@ private function createMemberNotification(
return $notification;
}


/**
* @param string $route
* @param array $params
*
* @return string
*/
private function linkToOCS(string $route, array $params = []): string {
$absolute = $this->urlGenerator->linkToOCSRouteAbsolute($route, $params);

return parse_url($absolute, PHP_URL_PATH);
}

public function markInvitationAsProcessed(Member $member): void {
if ($member->getUserType() !== Member::TYPE_USER || !$member->isLocal()) {
return;
Expand Down

0 comments on commit 3fb88af

Please sign in to comment.