Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2022-05-24 23:59:39 +0300
committerJoas Schilling <coding@schilljs.com>2022-05-25 09:50:53 +0300
commitb7b319c470b5322d13b8152b89a701d75f6200c4 (patch)
tree1cccef5674cb868e1d4319b7102dc966cd3d4cf5
parent7e3b71f07a9915355d9770eb97135f4dc26c05ab (diff)
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 <coding@schilljs.com>
-rw-r--r--lib/Chat/Parser/SystemMessage.php16
-rw-r--r--tests/integration/features/bootstrap/FeatureContext.php27
-rw-r--r--tests/integration/features/command/user-remove.feature22
3 files changed, 59 insertions, 6 deletions
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}'),
[
diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php
index 264a57629..ed3088b02 100644
--- a/tests/integration/features/bootstrap/FeatureContext.php
+++ b/tests/integration/features/bootstrap/FeatureContext.php
@@ -1760,16 +1760,31 @@ class FeatureContext implements Context, SnippetAcceptingContext {
return;
}
- Assert::assertCount(count($formData->getHash()), $messages, 'Message count does not match');
- Assert::assertEquals($formData->getHash(), array_map(function ($message) {
- return [
+ $expected = $formData->getHash();
+
+ Assert::assertCount(count($expected), $messages, 'Message count does not match');
+ Assert::assertEquals($expected, array_map(function ($message, $expected) {
+ $data = [
'room' => self::$tokenToIdentifier[$message['token']],
'actorType' => (string) $message['actorType'],
- 'actorId' => ($message['actorType'] === 'guests')? self::$sessionIdToUser[$message['actorId']]: (string) $message['actorId'],
- 'actorDisplayName' => (string) $message['actorDisplayName'],
+ 'actorId' => ($message['actorType'] === 'guests') ? self::$sessionIdToUser[$message['actorId']]: (string) $message['actorId'],
'systemMessage' => (string) $message['systemMessage'],
];
- }, $messages));
+
+ if (isset($expected['actorDisplayName'])) {
+ $data['actorDisplayName'] = $message['actorDisplayName'];
+ }
+
+ if (isset($expected['message'])) {
+ $data['message'] = $message['message'];
+ }
+
+ if (isset($expected['messageParameters'])) {
+ $data['messageParameters'] = json_encode($message['messageParameters']);
+ }
+
+ return $data;
+ }, $messages, $expected));
}
/**
diff --git a/tests/integration/features/command/user-remove.feature b/tests/integration/features/command/user-remove.feature
index b6e656355..9a9826a16 100644
--- a/tests/integration/features/command/user-remove.feature
+++ b/tests/integration/features/command/user-remove.feature
@@ -26,3 +26,25 @@ Feature: User remove
And user "participant1" sees the following attendees in room "room2" with 200 (v4)
| actorType | actorId | participantType |
| users | participant1 | 1 |
+
+ Scenario: Remove a user after there was a missed call
+ Given user "participant1" creates room "room" (v4)
+ | roomType | 1 |
+ | invite | participant2 |
+ Then user "participant1" joins room "room" with 200 (v4)
+ Then user "participant1" joins call "room" with 200 (v4)
+ Then user "participant1" leaves call "room" with 200 (v4)
+ Then user "participant1" leaves room "room" with 200 (v4)
+ And invoking occ with "talk:user:remove --user participant2"
+ And the command output contains the text "Users successfully removed from all rooms"
+ Then the command was successful
+ And user "participant2" is participant of the following rooms (v4)
+ And user "participant1" is participant of the following rooms (v4)
+ | id | name | type | participantType |
+ | room | participant2-displayname | 2 | 1 |
+ Then user "participant1" sees the following system messages in room "room" with 200
+ | room | actorType | actorId | systemMessage | message | messageParameters |
+ | room | users | participant1 | call_tried | You tried to call {user} | {"user":{"type":"highlight","id":"deleted_user","name":"participant2-displayname"}} |
+ | room | users | participant1 | call_left | You left the call | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} |
+ | room | users | participant1 | call_started | You started a call | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} |
+ | room | users | participant1 | conversation_created | You created the conversation | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} |