Skip to content

Commit

Permalink
fix(notification): Make sure the action URL is an absolute URL
Browse files Browse the repository at this point in the history
The URL needs to be absolute to work also on mobile and desktop clients.

Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux authored and backportbot[bot] committed Nov 19, 2024
1 parent 1edd6a7 commit cb11317
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 @@ -104,13 +104,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 @@ -149,7 +149,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 @@ -161,7 +161,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 @@ -216,19 +216,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 cb11317

Please sign in to comment.