Skip to content

Commit

Permalink
Merge pull request #12343 from nextcloud/backport/12341/stable28
Browse files Browse the repository at this point in the history
[stable28] fix(polls): Remove actor info from system message
  • Loading branch information
nickvergessen authored May 13, 2024
2 parents 4f316c3 + 45ed619 commit 5012ae1
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 @@ -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');
}
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 @@ -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) {
Expand All @@ -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;
Expand Down
Loading

0 comments on commit 5012ae1

Please sign in to comment.