Fix messages not loaded when commands are used with the MCU

When fetching chat messages ChatController may not return as many
messages as requested. In the past this meant that there were no more
messages in the room, but since the introduction of commands some
messages may not be returned because they should not be visible to the
participant fetching them. Thus, now the number of returned messages
does not mean anything regarding whether there are still more messages
in the room or not, but this can be known by looking for a "304 Not
modified" response (which is only sent when there are no more messages
in the room).

When no MUC is used the chat messages are polled again and again, so the
behaviour change explained above made no difference. However, when the
MCU is used the messages are fetched until there are no more messages in
the room and, then, they are only fetched when a new message is sent.
Checking whether there are more messages in the room or not was based on
the number of returned messages, so the fetch of messages until there
were no more messages in the room wrongly stopped when fetching a batch
of messages that included one not visible for the current participant.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2019-05-09 14:21:48 +02:00 коммит произвёл Joas Schilling
Родитель da938a5c2c
Коммит c883f9f688
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 7076EA9751AACDDA
1 изменённых файлов: 4 добавлений и 3 удалений

Просмотреть файл

@ -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();
}