Fix sending empty variable message for users that have no right to read variable

When a user had no right to read a variable and the variable changed, the user was notified nonetheless with an empty SubMessage, causing an error message in the front:

> Uncaught Error: Unexpected batch message type onmessage RoomConnection.ts:181 RoomConnection.ts:181:30 onmessage RoomConnection.ts:181

This fix closes #1613
This commit is contained in:
David Négrier 2021-12-03 16:07:42 +01:00
parent 9eb4206fe0
commit d23a64d074

View File

@ -100,11 +100,11 @@ export class PusherRoom {
// Let's dispatch this variable to all the listeners
for (const listener of this.listeners) {
const subMessage = new SubMessage();
if (!readableBy || listener.tags.includes(readableBy)) {
const subMessage = new SubMessage();
subMessage.setVariablemessage(variableMessage);
listener.emitInBatch(subMessage);
}
listener.emitInBatch(subMessage);
}
} else if (message.hasErrormessage()) {
const errorMessage = message.getErrormessage() as ErrorMessage;