From eace5bb38fa88ead2440d32207b17545726ec8d4 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 9 May 2023 07:32:54 +0200 Subject: [PATCH] fix(chat): Fix call summary with only numeric user ids Signed-off-by: Joas Schilling --- lib/Chat/Parser/SystemMessage.php | 7 ++++--- tests/php/Chat/Parser/SystemMessageTest.php | 9 +++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/Chat/Parser/SystemMessage.php b/lib/Chat/Parser/SystemMessage.php index e077c6bcd60..e8e19f8a076 100644 --- a/lib/Chat/Parser/SystemMessage.php +++ b/lib/Chat/Parser/SystemMessage.php @@ -900,9 +900,10 @@ protected function parseMissedCall(Room $room, array $parameters, string $curren protected function parseCall(string $message, array $parameters, array $params): array { if ($message === 'call_ended_everyone') { if ($params['actor']['type'] === 'user') { - $flipped = array_flip($parameters['users']); - unset($flipped[$params['actor']['id']]); - $parameters['users'] = array_flip($flipped); + $entry = array_keys($parameters['users'], $params['actor']['id'], true); + foreach ($entry as $i) { + unset($parameters['users'][$i]); + } } else { $parameters['guests']--; } diff --git a/tests/php/Chat/Parser/SystemMessageTest.php b/tests/php/Chat/Parser/SystemMessageTest.php index 3f257bdb858..260dafb8b71 100644 --- a/tests/php/Chat/Parser/SystemMessageTest.php +++ b/tests/php/Chat/Parser/SystemMessageTest.php @@ -1355,6 +1355,15 @@ public function dataParseCall(): array { ['user1' => ['data' => 'user2'], 'user2' => ['data' => 'user3'], 'user3' => ['data' => 'user4'], 'user4' => ['data' => 'user5']], ], ], + 'numeric users only' => [ + 'call_ended_everyone', + ['users' => ['123', '234', '345', '456', '576', '678'], 'guests' => 2, 'duration' => 42], + ['type' => 'user', 'id' => '123', 'name' => '123'], + [ + '{actor} ended the call with {user1}, {user2}, {user3}, {user4} and 3 others (Duration "duration")', + ['user1' => ['data' => '234'], 'user2' => ['data' => '345'], 'user3' => ['data' => '456'], 'user4' => ['data' => '576']], + ], + ], ]; }