diff --git a/js/signaling.js b/js/signaling.js index 31b3c564bdb..1bbc97087d5 100644 --- a/js/signaling.js +++ b/js/signaling.js @@ -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(); } diff --git a/lib/Controller/ChatController.php b/lib/Controller/ChatController.php index ed2437ecc80..b920f74780c 100644 --- a/lib/Controller/ChatController.php +++ b/lib/Controller/ChatController.php @@ -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) diff --git a/tests/integration/features/chat/commands.feature b/tests/integration/features/chat/commands.feature new file mode 100644 index 00000000000..c2e81752c9b --- /dev/null +++ b/tests/integration/features/chat/commands.feature @@ -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 | [] |