Skip to content

Commit

Permalink
feat(max-duration): Use a specific end message
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Oct 14, 2024
1 parent 4e0286f commit cc616c1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
40 changes: 31 additions & 9 deletions lib/Chat/Parser/SystemMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,13 @@ protected function parseCall(Room $room, string $message, array $parameters, arr

switch ($numUsers) {
case 0:
if ($message === 'call_ended' || $actorIsSystem) {
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})',
Expand All @@ -1127,7 +1133,9 @@ protected function parseCall(Room $room, string $message, array $parameters, arr
}
break;
case 1:
if ($message === 'call_ended' || $actorIsSystem) {
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) {
Expand All @@ -1140,13 +1148,17 @@ protected function parseCall(Room $room, string $message, array $parameters, arr
break;
case 2:
if ($parameters['guests'] === 0) {
if ($message === 'call_ended' || $actorIsSystem) {
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})');
}
} else {
if ($message === 'call_ended' || $actorIsSystem) {
if ($actorIsSystem) {
$subject = $this->l->t('Call with {user1}, {user2} and {user3} was ended, as it reached the maximum call duration (Duration {duration})');
} elseif ($message === 'call_ended') {
$subject = $this->l->t('Call with {user1}, {user2} and {user3} ended (Duration {duration})');
} else {
$subject = $this->l->t('{actor} ended the call with {user1}, {user2} and {user3} (Duration {duration})');
Expand All @@ -1156,13 +1168,17 @@ protected function parseCall(Room $room, string $message, array $parameters, arr
break;
case 3:
if ($parameters['guests'] === 0) {
if ($message === 'call_ended' || $actorIsSystem) {
if ($actorIsSystem) {
$subject = $this->l->t('Call with {user1}, {user2} and {user3} was ended, as it reached the maximum call duration (Duration {duration})');
} elseif ($message === 'call_ended') {
$subject = $this->l->t('Call with {user1}, {user2} and {user3} ended (Duration {duration})');
} else {
$subject = $this->l->t('{actor} ended the call with {user1}, {user2} and {user3} (Duration {duration})');
}
} else {
if ($message === 'call_ended' || $actorIsSystem) {
if ($actorIsSystem) {
$subject = $this->l->t('Call with {user1}, {user2}, {user3} and {user4} was ended, as it reached the maximum call duration (Duration {duration})');
} elseif ($message === 'call_ended') {
$subject = $this->l->t('Call with {user1}, {user2}, {user3} and {user4} ended (Duration {duration})');
} else {
$subject = $this->l->t('{actor} ended the call with {user1}, {user2}, {user3} and {user4} (Duration {duration})');
Expand All @@ -1172,13 +1188,17 @@ protected function parseCall(Room $room, string $message, array $parameters, arr
break;
case 4:
if ($parameters['guests'] === 0) {
if ($message === 'call_ended' || $actorIsSystem) {
if ($actorIsSystem) {
$subject = $this->l->t('Call with {user1}, {user2}, {user3} and {user4} was ended, as it reached the maximum call duration (Duration {duration})');
} elseif ($message === 'call_ended') {
$subject = $this->l->t('Call with {user1}, {user2}, {user3} and {user4} ended (Duration {duration})');
} else {
$subject = $this->l->t('{actor} ended the call with {user1}, {user2}, {user3} and {user4} (Duration {duration})');
}
} else {
if ($message === 'call_ended' || $actorIsSystem) {
if ($actorIsSystem) {
$subject = $this->l->t('Call with {user1}, {user2}, {user3}, {user4} and {user5} was ended, as it reached the maximum call duration (Duration {duration})');
} elseif ($message === 'call_ended') {
$subject = $this->l->t('Call with {user1}, {user2}, {user3}, {user4} and {user5} ended (Duration {duration})');
} else {
$subject = $this->l->t('{actor} ended the call with {user1}, {user2}, {user3}, {user4} and {user5} (Duration {duration})');
Expand All @@ -1188,7 +1208,9 @@ protected function parseCall(Room $room, string $message, array $parameters, arr
break;
case 5:
default:
if ($message === 'call_ended' || $actorIsSystem) {
if ($actorIsSystem) {
$subject = $this->l->t('Call with {user1}, {user2}, {user3}, {user4} and {user5} was ended, as it reached the maximum call duration (Duration {duration})');
} elseif ($message === 'call_ended') {
$subject = $this->l->t('Call with {user1}, {user2}, {user3}, {user4} and {user5} ended (Duration {duration})');
} else {
$subject = $this->l->t('{actor} ended the call with {user1}, {user2}, {user3}, {user4} and {user5} (Duration {duration})');
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Chat/Parser/SystemMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1534,7 +1534,7 @@ public static function dataParseCall(): array {
['users' => ['user1', 'user2', 'user3', 'user4'], 'guests' => 4, 'duration' => 42],
['type' => 'guest', 'id' => 'guest/system', 'name' => 'system'],
[
'Call with {user1}, {user2}, {user3}, {user4} and 4 guests ended (Duration "duration")',
'Call with {user1}, {user2}, {user3}, {user4} and 4 guests was ended, as it reached the maximum call duration (Duration "duration")',
['user1' => ['data' => 'user1'], 'user2' => ['data' => 'user2'], 'user3' => ['data' => 'user3'], 'user4' => ['data' => 'user4']],
],
],
Expand Down

0 comments on commit cc616c1

Please sign in to comment.