mirror of
https://github.com/DMOJ/online-judge.git
synced 2024-11-25 16:32:37 +08:00
Address sources of update leaks in websocket event daemon
This commit is contained in:
parent
952041e5e7
commit
11544751bd
@ -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;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user