Address sources of update leaks in websocket event daemon

This commit is contained in:
Tudor Brindus 2018-12-12 23:10:00 -05:00 committed by Tudor Brindus
parent 952041e5e7
commit 11544751bd

View File

@ -56,13 +56,14 @@ wss_receiver.on('connection', function (socket) {
},
set_filter: function (request) {
var filter = {};
if (Array.isArray(request.filter) && request.filter.every(function (channel, index, array) {
if (typeof channel != 'string')
return false;
filter[channel] = true;
return true;
if (Array.isArray(request.filter) && request.filter.length > 0 &&
request.filter.every(function (channel, index, array) {
if (typeof channel != 'string')
return false;
filter[channel] = true;
return true;
})) {
socket.filter = request.filter.length == 0 ? true : filter;
socket.filter = filter;
followers.add(socket);
messages.catch_up(socket);
} else {
@ -76,7 +77,7 @@ wss_receiver.on('connection', function (socket) {
};
socket.got_message = function (message) {
if (socket.filter === true || message.channel in socket.filter)
if (message.channel in socket.filter)
socket.send(JSON.stringify(message));
socket.last_msg = message.id;
};