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

[stable30] fix: omit 'with 0 guests' in system messages when call ends #13549

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
65 changes: 41 additions & 24 deletions lib/Chat/Parser/SystemMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -1112,39 +1112,56 @@ protected function parseCall(Room $room, string $message, array $parameters, arr

switch ($numUsers) {
case 0:
if ($actorIsSystem) {
$subject = $this->l->n(
'Call with %n guest was ended, as it reached the maximum call duration (Duration {duration})',
'Call with %n guests was ended, as it reached the maximum call duration (Duration {duration})',
$parameters['guests']
);
} elseif ($message === 'call_ended') {
$subject = $this->l->n(
'Call with %n guest ended (Duration {duration})',
'Call with %n guests ended (Duration {duration})',
$parameters['guests']
);
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 {
$subject = $this->l->n(
'{actor} ended the call with %n guest (Duration {duration})',
'{actor} ended the call with %n guests (Duration {duration})',
$parameters['guests']
);
if ($actorIsSystem) {
$subject = $this->l->n(
'Call with %n guest was ended, as it reached the maximum call duration (Duration {duration})',
'Call with %n guests was ended, as it reached the maximum call duration (Duration {duration})',
$parameters['guests']
);
} elseif ($message === 'call_ended') {
$subject = $this->l->n(
'Call with %n guest ended (Duration {duration})',
'Call with %n guests ended (Duration {duration})',
$parameters['guests']
);
} else {
$subject = $this->l->n(
'{actor} ended the call with %n guest (Duration {duration})',
'{actor} ended the call with %n guests (Duration {duration})',
$parameters['guests']
);
}
}
break;
case 1:
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 {
if ($parameters['guests'] === 0) {
if ($parameters['guests'] === 0) {
if ($actorIsSystem) {
$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} ended (Duration {duration})');
} else {
$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);
}
$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