diff --git a/websocket/daemon.js b/websocket/daemon.js index 01dd3a647..05b9940fa 100644 --- a/websocket/daemon.js +++ b/websocket/daemon.js @@ -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; };