From 75efeac6ff6b61d82dbb1fa92c49ca24e11bed55 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 20 Feb 2025 15:37:43 +0100 Subject: [PATCH] fix(call): Simplify wording for one-to-one calls Signed-off-by: Joas Schilling --- lib/Chat/Parser/SystemMessage.php | 27 ++++++++++++++++--- .../features/command/user-remove.feature | 8 +++--- .../command/user-transfer-ownership.feature | 2 +- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/lib/Chat/Parser/SystemMessage.php b/lib/Chat/Parser/SystemMessage.php index c7f3059ce1f..7cd80875f93 100644 --- a/lib/Chat/Parser/SystemMessage.php +++ b/lib/Chat/Parser/SystemMessage.php @@ -205,14 +205,26 @@ protected function parseMessage(Message $chatMessage): void { if ($silentCall) { if ($currentUserIsActor) { $parsedMessage = $this->l->t('You started a silent call'); + if ($room->getType() === Room::TYPE_ONE_TO_ONE || $room->getType() === Room::TYPE_ONE_TO_ONE_FORMER) { + $parsedMessage = $this->l->t('Outgoing silent call'); + } } else { $parsedMessage = $this->l->t('{actor} started a silent call'); + if ($room->getType() === Room::TYPE_ONE_TO_ONE || $room->getType() === Room::TYPE_ONE_TO_ONE_FORMER) { + $parsedMessage = $this->l->t('Incoming silent call'); + } } } else { if ($currentUserIsActor) { $parsedMessage = $this->l->t('You started a call'); + if ($room->getType() === Room::TYPE_ONE_TO_ONE || $room->getType() === Room::TYPE_ONE_TO_ONE_FORMER) { + $parsedMessage = $this->l->t('Outgoing call'); + } } else { $parsedMessage = $this->l->t('{actor} started a call'); + if ($room->getType() === Room::TYPE_ONE_TO_ONE || $room->getType() === Room::TYPE_ONE_TO_ONE_FORMER) { + $parsedMessage = $this->l->t('Incoming call'); + } } } } elseif ($message === 'call_joined') { @@ -1072,7 +1084,7 @@ protected function getGuestName(Room $room, string $actorType, string $actorId): protected function parseMissedCall(Room $room, array $parameters, ?string $currentActorId): array { if ($parameters['users'][0] !== $currentActorId) { return [ - $this->l->t('You missed a call from {user}'), + $this->l->t('Missed call'), [ 'user' => $this->getUser($parameters['users'][0]), ], @@ -1083,7 +1095,7 @@ protected function parseMissedCall(Room $room, array $parameters, ?string $curre if ($room->getType() !== Room::TYPE_ONE_TO_ONE) { // Can happen if a user was remove from a one-to-one room. return [ - $this->l->t('You tried to call {user}'), + $this->l->t('Missed call'), [ 'user' => [ 'type' => 'highlight', @@ -1104,7 +1116,7 @@ protected function parseMissedCall(Room $room, array $parameters, ?string $curre } return [ - $this->l->t('You tried to call {user}'), + $this->l->t('Missed call'), [ 'user' => $this->getUser($other), ], @@ -1118,6 +1130,15 @@ protected function parseCall(Room $room, string $message, array $parameters, arr $maxDuration = $this->appConfig->getAppValueInt('max_call_duration'); $maxDurationWasReached = $message === 'call_ended_everyone' && $actorIsSystem && $maxDuration > 0 && $parameters['duration'] > $maxDuration; + if ($room->getType() === Room::TYPE_ONE_TO_ONE || $room->getType() === Room::TYPE_ONE_TO_ONE_FORMER) { + $subject = $this->l->t('Call ended (Duration {duration})'); + $subject = str_replace('{duration}', $this->getDuration($parameters['duration']), $subject); + return [ + $subject, + $params, + ]; + } + if ($message === 'call_ended_everyone') { if ($params['actor']['type'] === 'user') { $entry = array_keys($parameters['users'], $params['actor']['id'], true); diff --git a/tests/integration/features/command/user-remove.feature b/tests/integration/features/command/user-remove.feature index 6edb13a409c..fdf3c5fdb78 100644 --- a/tests/integration/features/command/user-remove.feature +++ b/tests/integration/features/command/user-remove.feature @@ -74,9 +74,9 @@ Feature: command/user-remove And user "participant1" leaves room "room" with 200 (v4) Then user "participant1" sees the following system messages in room "room" with 200 | room | actorType | actorId | systemMessage | message | messageParameters | - | room | users | participant1 | call_tried | You tried to call {user} | {"user":{"type":"user","id":"participant2","name":"participant2-displayname","mention-id":"participant2"}} | + | room | users | participant1 | call_tried | Missed call | {"user":{"type":"user","id":"participant2","name":"participant2-displayname","mention-id":"participant2"}} | | room | users | participant1 | call_left | You left the call | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname","mention-id":"participant1"}} | - | room | users | participant1 | call_started | You started a call | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname","mention-id":"participant1"}} | + | room | users | participant1 | call_started | Outgoing call | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname","mention-id":"participant1"}} | | room | users | participant1 | conversation_created | You created the conversation | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname","mention-id":"participant1"}} | When reset signaling server requests And invoking occ with "talk:user:remove --user participant2" @@ -99,7 +99,7 @@ Feature: command/user-remove Then user "participant1" sees the following system messages in room "room" with 200 | room | actorType | actorId | systemMessage | message | messageParameters | | room | guests | cli | read_only | An administrator locked the conversation | {"actor":{"type":"guest","id":"guest\/cli","name":"Guest","mention-id":"guest\/cli"}} | - | room | users | participant1 | call_tried | You tried to call {user} | {"user":{"type":"highlight","id":"deleted_users","name":"participant2-displayname"}} | + | room | users | participant1 | call_tried | Missed call | {"user":{"type":"highlight","id":"deleted_users","name":"participant2-displayname"}} | | room | users | participant1 | call_left | You left the call | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname","mention-id":"participant1"}} | - | room | users | participant1 | call_started | You started a call | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname","mention-id":"participant1"}} | + | room | users | participant1 | call_started | Outgoing call | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname","mention-id":"participant1"}} | | room | users | participant1 | conversation_created | You created the conversation | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname","mention-id":"participant1"}} | diff --git a/tests/integration/features/command/user-transfer-ownership.feature b/tests/integration/features/command/user-transfer-ownership.feature index e8a69d67e96..7fcb3fb30e6 100644 --- a/tests/integration/features/command/user-transfer-ownership.feature +++ b/tests/integration/features/command/user-transfer-ownership.feature @@ -1,4 +1,4 @@ -Feature: command/user-remove +Feature: command/user-transfer-ownership Background: Given user "participant1" exists