diff --git a/lib/Chat/Parser/SystemMessage.php b/lib/Chat/Parser/SystemMessage.php index 7c3c607dcf3..debaa02115d 100644 --- a/lib/Chat/Parser/SystemMessage.php +++ b/lib/Chat/Parser/SystemMessage.php @@ -602,6 +602,8 @@ protected function parseMessage(Message $chatMessage): void { $parsedParameters['poll']['id'] = (string) $parsedParameters['poll']['id']; $parsedMessage = $this->l->t('Someone voted on the poll {poll}'); unset($parsedParameters['actor']); + + $chatMessage->setActor(Attendee::ACTOR_GUESTS, Attendee::ACTOR_ID_SYSTEM, ''); } else { throw new \OutOfBoundsException('Unknown subject'); } diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php index 74c7b31d9e2..2487dd83785 100644 --- a/tests/integration/features/bootstrap/FeatureContext.php +++ b/tests/integration/features/bootstrap/FeatureContext.php @@ -2679,7 +2679,16 @@ public function userSeesTheFollowingSystemMessagesInRoom($user, $identifier, $st return; } - $expected = $formData->getHash(); + $expected = array_map(static function (array $message) { + if (isset($message['messageParameters'])) { + $result = preg_match('/POLL_ID\(([^)]+)\)/', $message['messageParameters'], $matches); + if ($result) { + $message['messageParameters'] = str_replace($matches[0], '"' . self::$questionToPollId[$matches[1]] . '"', $message['messageParameters']); + } + } + return $message; + }, $formData->getHash()); + Assert::assertCount(count($expected), $messages, 'Message count does not match'); Assert::assertEquals($expected, array_map(function ($message, $expected) { @@ -2700,6 +2709,9 @@ public function userSeesTheFollowingSystemMessagesInRoom($user, $identifier, $st if (isset($expected['messageParameters'])) { $data['messageParameters'] = json_encode($message['messageParameters']); + if ($expected['messageParameters'] === '"IGNORE"') { + $data['messageParameters'] = '"IGNORE"'; + } } return $data; diff --git a/tests/integration/features/chat-2/poll.feature b/tests/integration/features/chat-2/poll.feature index 7389cd5686f..e59e2a977c0 100644 --- a/tests/integration/features/chat-2/poll.feature +++ b/tests/integration/features/chat-2/poll.feature @@ -96,6 +96,12 @@ Feature: chat-2/poll | status | closed | | votedSelf | not voted | | details | [{"actorType":"users","actorId":"participant1","actorDisplayName":"participant1-displayname","optionId":1}] | + Then user "participant1" sees the following system messages in room "room" with 200 (v1) + | room | actorType | actorId | systemMessage | message | messageParameters | + | room | users | participant1 | poll_closed | You ended the poll {poll} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"},"poll":{"type":"talk-poll","id":POLL_ID(What is the question?),"name":"What is the question?"}} | + | room | guests | system | poll_voted | Someone voted on the poll {poll} | {"poll":{"type":"talk-poll","id":POLL_ID(What is the question?),"name":"What is the question?"}} | + | room | users | participant1 | user_added | You added {user} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"},"user":{"type":"user","id":"participant2","name":"participant2-displayname"}} | + | room | users | participant1 | conversation_created | You created the conversation | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} | Scenario: Participants can update their votes but only while open Given user "participant1" creates room "room" (v4) @@ -147,6 +153,12 @@ Feature: chat-2/poll | votedSelf | [1] | | details | [{"actorType":"users","actorId":"participant1","actorDisplayName":"participant1-displayname","optionId":1}] | Then user "participant1" votes for options "[0]" on poll "What is the question?" in room "room" with 400 + Then user "participant1" sees the following system messages in room "room" with 200 (v1) + | room | actorType | actorId | systemMessage | message | messageParameters | + | room | users | participant1 | poll_closed | You ended the poll {poll} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"},"poll":{"type":"talk-poll","id":POLL_ID(What is the question?),"name":"What is the question?"}} | + | room | guests | system | poll_voted | Someone voted on the poll {poll} | {"poll":{"type":"talk-poll","id":POLL_ID(What is the question?),"name":"What is the question?"}} | + | room | guests | system | poll_voted | Someone voted on the poll {poll} | {"poll":{"type":"talk-poll","id":POLL_ID(What is the question?),"name":"What is the question?"}} | + | room | users | participant1 | conversation_created | You created the conversation | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} | Scenario: Participants can only vote for valid options Given user "participant1" creates room "room" (v4) @@ -159,6 +171,9 @@ Feature: chat-2/poll | maxVotes | unlimited | Then user "participant1" votes for options "[-1]" on poll "What is the question?" in room "room" with 400 Then user "participant1" votes for options "[2]" on poll "What is the question?" in room "room" with 400 + Then user "participant1" sees the following system messages in room "room" with 200 (v1) + | room | actorType | actorId | systemMessage | message | messageParameters | + | room | users | participant1 | conversation_created | You created the conversation | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} | Scenario: Participants can not exceed the maxVotes Given user "participant1" creates room "room" (v4) @@ -170,6 +185,9 @@ Feature: chat-2/poll | resultMode | public | | maxVotes | 1 | Then user "participant1" votes for options "[0,1]" on poll "What is the question?" in room "room" with 400 + Then user "participant1" sees the following system messages in room "room" with 200 (v1) + | room | actorType | actorId | systemMessage | message | messageParameters | + | room | users | participant1 | conversation_created | You created the conversation | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} | Scenario: Participants can vote for multiple options Given user "participant1" creates room "room" (v4) @@ -193,6 +211,10 @@ Feature: chat-2/poll | actorDisplayName | participant1-displayname | | status | open | | votedSelf | [0,1] | + Then user "participant1" sees the following system messages in room "room" with 200 (v1) + | room | actorType | actorId | systemMessage | message | messageParameters | + | room | guests | system | poll_voted | Someone voted on the poll {poll} | {"poll":{"type":"talk-poll","id":POLL_ID(What is the question?),"name":"What is the question?"}} | + | room | users | participant1 | conversation_created | You created the conversation | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} | Scenario: Participants can not vote for the same option multiple times Given user "participant1" creates room "room" (v4) @@ -204,6 +226,9 @@ Feature: chat-2/poll | resultMode | public | | maxVotes | unlimited | Then user "participant1" votes for options "[1,1]" on poll "What is the question?" in room "room" with 400 + Then user "participant1" sees the following system messages in room "room" with 200 (v1) + | room | actorType | actorId | systemMessage | message | messageParameters | + | room | users | participant1 | conversation_created | You created the conversation | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} | Scenario: Non-moderators can also create polls and close it themselves Given user "participant1" creates room "room" (v4) @@ -232,6 +257,11 @@ Feature: chat-2/poll | status | closed | | votedSelf | not voted | | details | {} | + Then user "participant1" sees the following system messages in room "room" with 200 (v1) + | room | actorType | actorId | systemMessage | message | messageParameters | + | room | users | participant2 | poll_closed | {actor} ended the poll {poll} | {"actor":{"type":"user","id":"participant2","name":"participant2-displayname"},"poll":{"type":"talk-poll","id":POLL_ID(What is the question?),"name":"What is the question?"}} | + | room | users | participant1 | user_added | You added {user} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"},"user":{"type":"user","id":"participant2","name":"participant2-displayname"}} | + | room | users | participant1 | conversation_created | You created the conversation | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} | Scenario: Non-moderators can not create polls without chat permission Given user "participant1" creates room "room" (v4) @@ -270,6 +300,11 @@ Feature: chat-2/poll | status | closed | | votedSelf | not voted | | details | {} | + Then user "participant1" sees the following system messages in room "room" with 200 (v1) + | room | actorType | actorId | systemMessage | message | messageParameters | + | room | users | participant1 | poll_closed | You ended the poll {poll} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"},"poll":{"type":"talk-poll","id":POLL_ID(What is the question?),"name":"What is the question?"}} | + | room | users | participant1 | user_added | You added {user} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"},"user":{"type":"user","id":"participant2","name":"participant2-displayname"}} | + | room | users | participant1 | conversation_created | You created the conversation | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} | Scenario: There are system messages for opening, voting and closing on public polls Given user "participant1" creates room "room" (v4) @@ -322,17 +357,16 @@ Feature: chat-2/poll | votedSelf | [0] | | details | [{"actorType":"users","actorId":"participant1","actorDisplayName":"participant1-displayname","optionId":0},{"actorType":"users","actorId":"participant2","actorDisplayName":"participant2-displayname","optionId":1}] | Then user "participant1" sees the following system messages in room "room" with 200 (v1) - | room | actorType | actorId | actorDisplayName | systemMessage | - | room | users | participant1 | participant1-displayname | poll_closed | - | room | users | participant2 | participant2-displayname | poll_voted | - | room | users | participant1 | participant1-displayname | poll_voted | - | room | users | participant1 | participant1-displayname | user_added | - | room | users | participant1 | participant1-displayname | conversation_created | + | room | actorType | actorId | systemMessage | message | messageParameters | + | room | users | participant1 | poll_closed | You ended the poll {poll} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"},"poll":{"type":"talk-poll","id":POLL_ID(What is the question?),"name":"What is the question?"}} | + | room | guests | system | poll_voted | Someone voted on the poll {poll} | {"poll":{"type":"talk-poll","id":POLL_ID(What is the question?),"name":"What is the question?"}} | + | room | guests | system | poll_voted | Someone voted on the poll {poll} | {"poll":{"type":"talk-poll","id":POLL_ID(What is the question?),"name":"What is the question?"}} | + | room | users | participant1 | user_added | You added {user} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"},"user":{"type":"user","id":"participant2","name":"participant2-displayname"}} | + | room | users | participant1 | conversation_created | You created the conversation | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} | Then user "participant1" sees the following messages in room "room" with 200 (v1) | room | actorType | actorId | actorDisplayName | message | messageParameters | | room | users | participant1 | participant1-displayname | {object} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"},"object":{"type":"talk-poll","id":POLL_ID(What is the question?),"name":"What is the question?"}} | - Scenario: There are only system messages for opening and closing on hidden polls Given user "participant1" creates room "room" (v4) | roomType | 2 | @@ -469,6 +503,11 @@ Feature: chat-2/poll | actorDisplayName | participant1-displayname | | status | closed | | votedSelf | not voted | + Then user "participant1" sees the following system messages in room "room" with 200 + | room | actorType | actorId | systemMessage | message | messageParameters | + | room | users | participant1 | poll_closed | You ended the poll {poll} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"},"poll":{"type":"talk-poll","id":POLL_ID(What is the question?),"name":"What is the question?"}} | + | room | users | participant1 | user_added | You added {user} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"},"user":{"type":"user","id":"participant2","name":"participant2-displayname"}} | + | room | users | participant1 | conversation_created | You created the conversation | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} | Scenario: Number of voters and votes are restricted to the very same poll Given user "participant1" creates room "room" (v4) @@ -524,6 +563,12 @@ Feature: chat-2/poll | actorDisplayName | participant2-displayname | | status | open | | votedSelf | [1] | + Then user "participant1" sees the following system messages in room "room" with 200 + | room | actorType | actorId | systemMessage | message | messageParameters | + | room | guests | system | poll_voted | Someone voted on the poll {poll} | {"poll":{"type":"talk-poll","id":POLL_ID(Another one ...),"name":"Another one ..."}} | + | room | guests | system | poll_voted | Someone voted on the poll {poll} | {"poll":{"type":"talk-poll","id":POLL_ID(What is the question?),"name":"What is the question?"}} | + | room | users | participant1 | user_added | You added {user} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"},"user":{"type":"user","id":"participant2","name":"participant2-displayname"}} | + | room | users | participant1 | conversation_created | You created the conversation | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} | Scenario: Remove all votes Given user "participant1" creates room "room" (v4) @@ -574,6 +619,12 @@ Feature: chat-2/poll | actorDisplayName | participant1-displayname | | status | open | | votedSelf | [] | + Then user "participant1" sees the following system messages in room "room" with 200 + | room | actorType | actorId | systemMessage | message | messageParameters | + | room | guests | system | poll_voted | Someone voted on the poll {poll} | {"poll":{"type":"talk-poll","id":POLL_ID(What is the question?),"name":"What is the question?"}} | + | room | guests | system | poll_voted | Someone voted on the poll {poll} | {"poll":{"type":"talk-poll","id":POLL_ID(What is the question?),"name":"What is the question?"}} | + | room | users | participant1 | user_added | You added {user} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"},"user":{"type":"user","id":"participant2","name":"participant2-displayname"}} | + | room | users | participant1 | conversation_created | You created the conversation | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} | Scenario: Empty question and options Given user "participant1" creates room "room" (v4) @@ -652,6 +703,13 @@ Feature: chat-2/poll | status | closed | | votedSelf | [] | | details | [{"actorType":"deleted_users","actorId":"deleted_users","actorDisplayName":"","optionId":0}] | + Then user "participant1" sees the following system messages in room "room" with 200 (v1) + | room | actorType | actorId | systemMessage | message | messageParameters | + | room | users | admin | user_removed | {actor} removed {user} | "IGNORE" | + | room | deleted_users | deleted_users | poll_closed | {actor} ended the poll {poll} | {"actor":{"type":"highlight","id":"deleted_user","name":"Deleted user"},"poll":{"type":"talk-poll","id":POLL_ID(What is the question?),"name":"What is the question?"}} | + | room | guests | system | poll_voted | Someone voted on the poll {poll} | {"poll":{"type":"talk-poll","id":POLL_ID(What is the question?),"name":"What is the question?"}} | + | room | users | participant1 | user_added | You added {user} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"},"user":{"type":"highlight","id":"deleted_user","name":"Deleted user"}} | + | room | users | participant1 | conversation_created | You created the conversation | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} | Scenario: Deleting the poll message removes all details Given user "participant1" creates room "room" (v4) @@ -676,6 +734,11 @@ Feature: chat-2/poll And user "participant1" sees the following messages in room "room" with 200 (v1) | room | actorType | actorId | actorDisplayName | message | messageParameters | | room | users | participant2 | participant2-displayname | Message deleted by you | "IGNORE" | + Then user "participant1" sees the following system messages in room "room" with 200 (v1) + | room | actorType | actorId | systemMessage | message | messageParameters | + | room | users | participant1 | message_deleted | You deleted a message | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} | + | room | users | participant1 | user_added | You added {user} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"},"user":{"type":"user","id":"participant2","name":"participant2-displayname"}} | + | room | users | participant1 | conversation_created | You created the conversation | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} | Scenario: Deleting a closed poll message removes also the close message Given user "participant1" creates room "room" (v4) @@ -715,6 +778,12 @@ Feature: chat-2/poll | room | actorType | actorId | actorDisplayName | message | messageParameters | | room | users | participant2 | participant2-displayname | Message deleted by you | "IGNORE" | | room | users | participant2 | participant2-displayname | Message deleted by you | "IGNORE" | + Then user "participant1" sees the following system messages in room "room" with 200 (v1) + | room | actorType | actorId | systemMessage | message | messageParameters | + | room | users | participant1 | message_deleted | You deleted a message | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} | + | room | users | participant1 | message_deleted | You deleted a message | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} | + | room | users | participant1 | user_added | You added {user} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"},"user":{"type":"user","id":"participant2","name":"participant2-displayname"}} | + | room | users | participant1 | conversation_created | You created the conversation | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} | Scenario: Deleting the chat history also deletes polls Given user "participant1" creates room "room" (v4) @@ -733,3 +802,6 @@ Feature: chat-2/poll Then user "participant1" sees poll "What is the question?" in room "room" with 404 Then user "participant2" sees poll "What is the question?" in room "room" with 404 And user "participant1" sees the following messages in room "room" with 200 (v1) + Then user "participant1" sees the following system messages in room "room" with 200 (v1) + | room | actorType | actorId | systemMessage | message | messageParameters | + | room | users | participant1 | history_cleared | You cleared the history of the conversation | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} |