diff --git a/lib/Chat/Parser/SystemMessage.php b/lib/Chat/Parser/SystemMessage.php index 71204f19dab..4d46806f1a9 100644 --- a/lib/Chat/Parser/SystemMessage.php +++ b/lib/Chat/Parser/SystemMessage.php @@ -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) { diff --git a/tests/php/Chat/Parser/SystemMessageTest.php b/tests/php/Chat/Parser/SystemMessageTest.php index 6885e335a3d..ea5ef646ffa 100644 --- a/tests/php/Chat/Parser/SystemMessageTest.php +++ b/tests/php/Chat/Parser/SystemMessageTest.php @@ -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], @@ -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],