Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: omit 'with 0 guests' in system messages when call ends #13545

Merged
merged 2 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions lib/Chat/Parser/SystemMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,16 @@ protected function parseCall(Room $room, string $message, array $parameters, arr

switch ($numUsers) {
case 0:
if ($parameters['guests'] === 0) {
// Call without users and guests
if ($actorIsSystem) {
$subject = $this->l->t('Call was ended, as it reached the maximum call duration (Duration {duration})');
} elseif ($message === 'call_ended') {
$subject = $this->l->t('Call ended (Duration {duration})');
} else {
$subject = $this->l->t('{actor} ended the call (Duration {duration})');
}
} else {
if ($actorIsSystem) {
$subject = $this->l->n(
'Call with %n guest was ended, as it reached the maximum call duration (Duration {duration})',
Expand All @@ -1131,20 +1141,27 @@ protected function parseCall(Room $room, string $message, array $parameters, arr
$parameters['guests']
);
}
}
break;
case 1:
if ($parameters['guests'] === 0) {
if ($actorIsSystem) {
$subject = $this->l->t('Call with {user1} and {user2} was ended, as it reached the maximum call duration (Duration {duration})');
$subject = $this->l->t('Call with {user1} was ended, as it reached the maximum call duration (Duration {duration})');
} elseif ($message === 'call_ended') {
$subject = $this->l->t('Call with {user1} and {user2} ended (Duration {duration})');
$subject = $this->l->t('Call with {user1} ended (Duration {duration})');
} else {
if ($parameters['guests'] === 0) {
$subject = $this->l->t('{actor} ended the call with {user1} (Duration {duration})');
}
} else {
if ($actorIsSystem) {
$subject = $this->l->t('Call with {user1} and {user2} was ended, as it reached the maximum call duration (Duration {duration})');
} elseif ($message === 'call_ended') {
$subject = $this->l->t('Call with {user1} and {user2} ended (Duration {duration})');
} else {
$subject = $this->l->t('{actor} ended the call with {user1} and {user2} (Duration {duration})');
}
}
$subject = str_replace('{user2}', $this->l->n('%n guest', '%n guests', $parameters['guests']), $subject);
}
break;
case 2:
if ($parameters['guests'] === 0) {
Expand Down
18 changes: 18 additions & 0 deletions tests/php/Chat/Parser/SystemMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,15 @@ public function testGetGuestNameThrows(): void {

public static function dataParseCall(): array {
return [
'1 user' => [
'call_ended',
['users' => ['user1'], 'guests' => 0, 'duration' => 42],
['type' => 'user', 'id' => 'admin', 'name' => 'Admin'],
[
'Call with {user1} ended (Duration "duration")',
['user1' => ['data' => 'user1']],
],
],
'1 user + guests' => [
'call_ended',
['users' => ['user1'], 'guests' => 3, 'duration' => 42],
Expand Down Expand Up @@ -1419,6 +1428,15 @@ public static function dataParseCall(): array {
['user1' => ['data' => 'user2']],
],
],
'meeting 1 user' => [
'call_ended_everyone',
['users' => ['user1'], 'guests' => 0, 'duration' => 42],
['type' => 'user', 'id' => 'user1', 'name' => 'user1'],
[
'{actor} ended the call (Duration "duration")',
[],
],
],
'meeting 1 user + guests' => [
'call_ended_everyone',
['users' => ['user1'], 'guests' => 3, 'duration' => 42],
Expand Down
Loading