Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable16] Fix messages not loaded when commands are used with the MCU #1808

Merged
merged 3 commits into from
May 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions js/signaling.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,10 @@

this._waitTimeUntilRetry = 1;

// Fetch more messages if PHP backend or a whole batch has been received
// (more messages might be available in this case).
if (this.receiveMessagesAgain || (messages && messages.length === this.chatBatchSize)) {
// Fetch more messages if PHP backend, or if the returned status is not
// "304 Not modified" (as in that case there could be more messages that
// need to be fetched).
if (this.receiveMessagesAgain || xhr.status !== 304) {
this._receiveChatMessages();
}

Expand Down
9 changes: 9 additions & 0 deletions lib/Controller/ChatController.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,15 @@ public function sendMessage(string $message, string $actorDisplayName = ''): Dat
* If messages have been returned (status=200) the new $lastKnownMessageId
* for the follow up query is available as `X-Chat-Last-Given` header.
*
* The limit specifies the maximum number of messages that will be returned,
* although the actual number of returned messages could be lower if some
* messages are not visible to the participant. Note that if none of the
* messages are visible to the participant the returned number of messages
* will be 0, yet the status will still be 200. Also note that
* `X-Chat-Last-Given` may reference a message not visible and thus not
* returned, but it should be used nevertheless as the $lastKnownMessageId
* for the follow up query.
*
* @param int $lookIntoFuture Polling for new messages (1) or getting the history of the chat (0)
* @param int $limit Number of chat messages to receive (100 by default, 200 at most)
* @param int $lastKnownMessageId The last known message (serves as offset)
Expand Down
33 changes: 33 additions & 0 deletions tests/integration/features/chat/commands.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Feature: chat/commands
Background:
Given user "participant1" exists
Given user "participant2" exists

Scenario: user can see own help command and others can not
Given user "participant1" creates room "group room"
| roomType | 2 |
| roomName | room |
And user "participant1" adds "participant2" to room "group room" with 200
When user "participant1" sends message "/help" to room "group room" with 201
Then user "participant1" sees the following messages in room "group room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters |
| group room | bots | talk | talk-bot | There are currently no commands available. | [] |
And user "participant2" sees the following messages in room "group room" with 200

Scenario: user can see own help command along with regular messages and others can not
Given user "participant1" creates room "group room"
| roomType | 2 |
| roomName | room |
And user "participant1" adds "participant2" to room "group room" with 200
When user "participant1" sends message "Message 1" to room "group room" with 201
And user "participant1" sends message "/help" to room "group room" with 201
And user "participant1" sends message "Message 2" to room "group room" with 201
Then user "participant1" sees the following messages in room "group room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters |
| group room | users | participant1 | participant1-displayname | Message 2 | [] |
| group room | bots | talk | talk-bot | There are currently no commands available. | [] |
| group room | users | participant1 | participant1-displayname | Message 1 | [] |
And user "participant2" sees the following messages in room "group room" with 200
| room | actorType | actorId | actorDisplayName | message | messageParameters |
| group room | users | participant1 | participant1-displayname | Message 2 | [] |
| group room | users | participant1 | participant1-displayname | Message 1 | [] |