Browse Source

Move my reactions to parent

Signed-off-by: Vitor Mattos <vitor@php.rio>
pull/7173/head
Vitor Mattos 4 years ago
parent
commit
dd46c91eeb
No known key found for this signature in database GPG Key ID: B7AB4B76A7CA7318
  1. 4
      lib/Controller/ChatController.php
  2. 5
      tests/integration/features/bootstrap/FeatureContext.php
  3. 8
      tests/integration/features/reaction/react.feature

4
lib/Controller/ChatController.php

@ -555,14 +555,14 @@ class ChatController extends AEnvironmentAwareController {
// Inject the reactions self into the $messages array
foreach ($reactionsById as $messageId => $reactions) {
if (isset($messages[$commentIdToIndex[$messageId]])) {
$messages[$commentIdToIndex[$messageId]]['reactions']['self'] = $reactions;
$messages[$commentIdToIndex[$messageId]]['myReactions'] = $reactions;
}
// Add the self part also to potential parent elements
if (isset($parentMap[$messageId])) {
foreach ($parentMap[$messageId] as $mid) {
if (isset($messages[$commentIdToIndex[$mid]])) {
$messages[$commentIdToIndex[$mid]]['parent']['reactions']['self'] = $reactions;
$messages[$commentIdToIndex[$mid]]['parent']['myReactions'] = $reactions;
}
}
}

5
tests/integration/features/bootstrap/FeatureContext.php

@ -1705,6 +1705,11 @@ class FeatureContext implements Context, SnippetAcceptingContext {
}
if ($includeReactions) {
$data['reactions'] = json_encode($message['reactions'], JSON_UNESCAPED_UNICODE);
if (isset($message['myReactions'])) {
$data['myReactions'] = json_encode($message['myReactions'], JSON_UNESCAPED_UNICODE);
} else {
$data['myReactions'] = null;
}
}
return $data;
}, $messages));

8
tests/integration/features/reaction/react.feature

@ -18,16 +18,16 @@ Feature: reaction/react
| room | users | participant1 | participant1-displayname | user_added |
| room | users | participant1 | participant1-displayname | conversation_created |
Then user "participant1" sees the following messages in room "room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | reactions |
| room | users | participant1 | participant1-displayname | Message 1 | [] | {"👍":1} |
| room | actorType | actorId | actorDisplayName | message | messageParameters | reactions | myReactions |
| room | users | participant1 | participant1-displayname | Message 1 | [] | {"👍":1} | |
And user "participant1" react with "👍" on message "Message 1" to room "room" with 201
| actorType | actorId | actorDisplayName | reaction |
| users | participant1 | participant1-displayname | 👍 |
| users | participant2 | participant2-displayname | 👍 |
And user "participant1" react with "🚀" on message "Message 1" to room "room" with 201
Then user "participant1" sees the following messages in room "room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters | reactions |
| room | users | participant1 | participant1-displayname | Message 1 | [] | {"👍":2,"🚀":1,"self":["👍","🚀"]} |
| room | actorType | actorId | actorDisplayName | message | messageParameters | reactions | myReactions |
| room | users | participant1 | participant1-displayname | Message 1 | [] | {"👍":2,"🚀":1} | ["👍","🚀"] |
Then user "participant1" sees the following system messages in room "room" with 200
| room | actorType | actorId | actorDisplayName | systemMessage |
| room | users | participant1 | participant1-displayname | reaction |

Loading…
Cancel
Save