From b7b319c470b5322d13b8152b89a701d75f6200c4 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 24 May 2022 22:59:39 +0200 Subject: Fix "Invalid argument supplied for foreach() at SystemMessage.php#720" This can happen if a user gets deleted from a one-to-one conversation Signed-off-by: Joas Schilling --- lib/Chat/Parser/SystemMessage.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'lib') diff --git a/lib/Chat/Parser/SystemMessage.php b/lib/Chat/Parser/SystemMessage.php index e8165712a..68a794406 100644 --- a/lib/Chat/Parser/SystemMessage.php +++ b/lib/Chat/Parser/SystemMessage.php @@ -716,6 +716,21 @@ class SystemMessage { ]; } + if ($room->getType() !== Room::TYPE_ONE_TO_ONE) { + // Can happen if a user was remove from a one-to-one room. + return [ + $this->l->t('You tried to call {user}'), + [ + 'user' => [ + 'type' => 'highlight', + 'id' => 'deleted_user', + 'name' => $room->getName(), + ], + ], + 'call_tried', + ]; + } + $participants = json_decode($room->getName(), true); $other = ''; foreach ($participants as $participant) { @@ -723,6 +738,7 @@ class SystemMessage { $other = $participant; } } + return [ $this->l->t('You tried to call {user}'), [ -- cgit v1.2.3