Skip to content

Commit

Permalink
fix(polls): Remove actor info from system message
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen authored and backportbot[bot] committed May 13, 2024
1 parent c30b78c commit ae4a53d
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 8 deletions.
2 changes: 2 additions & 0 deletions lib/Chat/Parser/SystemMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,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');
}
Expand Down
14 changes: 13 additions & 1 deletion tests/integration/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -2871,7 +2871,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:' . "\n" . json_encode($messages, JSON_PRETTY_PRINT));
Assert::assertEquals($expected, array_map(function ($message, $expected) {
Expand All @@ -2892,6 +2901,9 @@ public function userSeesTheFollowingSystemMessagesInRoom($user, $identifier, $st

if (isset($expected['messageParameters'])) {
$data['messageParameters'] = json_encode($message['messageParameters']);
if ($expected['messageParameters'] === '"IGNORE"') {
$data['messageParameters'] = '"IGNORE"';
}
}

if (isset($expected['silent'])) {
Expand Down
Loading

0 comments on commit ae4a53d

Please sign in to comment.