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