Skip to content

Commit

Permalink
Merge pull request #11621 from nextcloud/backport/11610/stable28
Browse files Browse the repository at this point in the history
[stable28] fix(notifications): Fix notification action label length with utf8 la…
  • Loading branch information
nickvergessen committed Feb 21, 2024
2 parents aecdfe8 + 3af26d2 commit 05425e3
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions lib/Notification/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -805,10 +805,10 @@ protected function parseChatMessage(INotification $notification, Room $room, Par
}

if ($notification->getObjectType() === 'reminder') {
$notification = $this->addActionButton($notification, $l->t('View message'));
$notification = $this->addActionButton($notification, 'message_view', $l->t('View message'));

$action = $notification->createAction();
$action->setLabel($l->t('Dismiss reminder'))
$action->setLabel('reminder_dismiss')
->setParsedLabel($l->t('Dismiss reminder'))
->setLink(
$this->url->linkToOCSRouteAbsolute(
Expand All @@ -824,7 +824,7 @@ protected function parseChatMessage(INotification $notification, Room $room, Par

$notification->addParsedAction($action);
} else {
$notification = $this->addActionButton($notification, $l->t('View chat'), false);
$notification = $this->addActionButton($notification, 'chat_view', $l->t('View chat'), false);
}

if ($richSubjectParameters['user'] === null) {
Expand Down Expand Up @@ -907,9 +907,9 @@ protected function parseInvitation(INotification $notification, Room $room, IL10
if ($room->getType() === Room::TYPE_ONE_TO_ONE || $room->getType() === Room::TYPE_ONE_TO_ONE_FORMER) {
$subject = $l->t('{user} invited you to a private conversation');
if ($this->participantService->hasActiveSessionsInCall($room)) {
$notification = $this->addActionButton($notification, $l->t('Join call'), true, true);
$notification = $this->addActionButton($notification, 'call_view', $l->t('Join call'), true, true);
} else {
$notification = $this->addActionButton($notification, $l->t('View chat'), false);
$notification = $this->addActionButton($notification, 'chat_view', $l->t('View chat'), false);
}

$notification
Expand All @@ -933,9 +933,9 @@ protected function parseInvitation(INotification $notification, Room $room, IL10
} elseif (\in_array($room->getType(), [Room::TYPE_GROUP, Room::TYPE_PUBLIC], true)) {
$subject = $l->t('{user} invited you to a group conversation: {call}');
if ($this->participantService->hasActiveSessionsInCall($room)) {
$notification = $this->addActionButton($notification, $l->t('Join call'), true, true);
$notification = $this->addActionButton($notification, 'call_view', $l->t('Join call'), true, true);
} else {
$notification = $this->addActionButton($notification, $l->t('View chat'), false);
$notification = $this->addActionButton($notification, 'chat_view', $l->t('View chat'), false);
}

$notification
Expand Down Expand Up @@ -983,10 +983,10 @@ protected function parseCall(INotification $notification, Room $room, IL10N $l):
$userDisplayName = $this->userManager->getDisplayName($calleeId);
if ($userDisplayName !== null) {
if ($this->notificationManager->isPreparingPushNotification() || $this->participantService->hasActiveSessionsInCall($room)) {
$notification = $this->addActionButton($notification, $l->t('Answer call'), true, true);
$notification = $this->addActionButton($notification, 'call_view', $l->t('Answer call'), true, true);
$subject = $l->t('{user} would like to talk with you');
} else {
$notification = $this->addActionButton($notification, $l->t('Call back'));
$notification = $this->addActionButton($notification, 'call_view', $l->t('Call back'));
$subject = $l->t('You missed a call from {user}');
}

Expand All @@ -1013,10 +1013,10 @@ protected function parseCall(INotification $notification, Room $room, IL10N $l):
}
} elseif (\in_array($room->getType(), [Room::TYPE_GROUP, Room::TYPE_PUBLIC], true)) {
if ($this->notificationManager->isPreparingPushNotification() || $this->participantService->hasActiveSessionsInCall($room)) {
$notification = $this->addActionButton($notification, $l->t('Join call'), true, true);
$notification = $this->addActionButton($notification, 'call_view', $l->t('Join call'), true, true);
$subject = $l->t('A group call has started in {call}');
} else {
$notification = $this->addActionButton($notification, $l->t('View chat'), false);
$notification = $this->addActionButton($notification, 'chat_view', $l->t('View chat'), false);
$subject = $l->t('You missed a group call in {call}');
}

Expand Down Expand Up @@ -1071,9 +1071,9 @@ protected function parsePasswordRequest(INotification $notification, Room $room,

$callIsActive = $this->notificationManager->isPreparingPushNotification() || $this->participantService->hasActiveSessionsInCall($room);
if ($callIsActive) {
$notification = $this->addActionButton($notification, $l->t('Answer call'), true, true);
$notification = $this->addActionButton($notification, 'call_view', $l->t('Answer call'), true, true);
} else {
$notification = $this->addActionButton($notification, $l->t('Call back'));
$notification = $this->addActionButton($notification, 'call_view', $l->t('Call back'));
}

if ($share->getShareType() === IShare::TYPE_EMAIL) {
Expand Down Expand Up @@ -1110,14 +1110,14 @@ protected function parsePasswordRequest(INotification $notification, Room $room,
return $notification;
}

protected function addActionButton(INotification $notification, string $label, bool $primary = true, bool $directCallLink = false): INotification {
protected function addActionButton(INotification $notification, string $labelKey, string $label, bool $primary = true, bool $directCallLink = false): INotification {
$link = $notification->getLink();
if ($directCallLink) {
$link .= '#direct-call';
}

$action = $notification->createAction();
$action->setLabel($label)
$action->setLabel($labelKey)
->setParsedLabel($label)
->setLink($link, IAction::TYPE_WEB)
->setPrimary($primary);
Expand Down

0 comments on commit 05425e3

Please sign in to comment.