mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-18 03:31:03 +01:00
removed commented out stuff removed topics.enter
This commit is contained in:
@@ -137,11 +137,6 @@ SocketCategories.getTopicCount = function(socket, cid, callback) {
|
||||
categories.getCategoryField(cid, 'topic_count', callback);
|
||||
};
|
||||
|
||||
SocketCategories.getUsersInCategory = function(socket, cid, callback) {
|
||||
var uids = websockets.getUidsInRoom('category_' + cid);
|
||||
user.getUsersFields(uids, ['uid', 'userslug', 'username', 'picture'], callback);
|
||||
};
|
||||
|
||||
SocketCategories.getCategoriesByPrivilege = function(socket, privilege, callback) {
|
||||
categories.getCategoriesByPrivilege('categories:cid', socket.uid, privilege, callback);
|
||||
};
|
||||
|
||||
@@ -86,13 +86,6 @@ function onDisconnect(socket, data) {
|
||||
if (socketCount <= 1) {
|
||||
socket.broadcast.emit('event:user_status_change', {uid: socket.uid, status: 'offline'});
|
||||
}
|
||||
|
||||
// see https://github.com/Automattic/socket.io/issues/1814
|
||||
// data.rooms.forEach(function(roomName) {
|
||||
// if (roomName.startsWith('topic')) {
|
||||
// io.in(roomName).emit('event:user_leave', socket.uid);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
rooms.leaveAll(socket, data.rooms);
|
||||
}
|
||||
@@ -264,6 +257,7 @@ Sockets.isUsersOnline = function(uids, callback) {
|
||||
};
|
||||
|
||||
Sockets.getUsersInRoom = function (uid, roomName, start, stop, callback) {
|
||||
winston.warn('[deprecated] Sockets.getUsersInRoom')
|
||||
callback(null, {
|
||||
users: [],
|
||||
room: roomName,
|
||||
@@ -271,69 +265,12 @@ Sockets.getUsersInRoom = function (uid, roomName, start, stop, callback) {
|
||||
hidden: 0
|
||||
});
|
||||
return;
|
||||
|
||||
if (!roomName) {
|
||||
return;
|
||||
}
|
||||
|
||||
var uids = Sockets.getUidsInRoom(roomName);
|
||||
var total = uids.length;
|
||||
if (stop !== -1) {
|
||||
uids = uids.slice(start, stop);
|
||||
}
|
||||
|
||||
if (uid && uids.indexOf(uid.toString()) === -1) {
|
||||
uids = [uid].concat(uids);
|
||||
}
|
||||
|
||||
if (!uids.length) {
|
||||
return callback(null, {users: [], total: 0 , room: roomName});
|
||||
}
|
||||
user.getUsersFields(uids, ['uid', 'username', 'userslug', 'picture', 'status'], function(err, users) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
users = users.filter(function(user) {
|
||||
return user && user.status !== 'offline';
|
||||
});
|
||||
|
||||
callback(null, {
|
||||
users: users,
|
||||
room: roomName,
|
||||
total: users.length ? total : 0,
|
||||
hidden: Math.max(0, total - uids.length)
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Sockets.getUidsInRoom = function(roomName, callback) {
|
||||
winston.warn('[deprecated] Sockets.getUidsInRoom')
|
||||
callback = callback || function() {};
|
||||
|
||||
var uids = [];
|
||||
|
||||
var socketids = rooms.clients(roomName);
|
||||
if (!Array.isArray(socketids) || !socketids.length) {
|
||||
callback(null, []);
|
||||
return [];
|
||||
}
|
||||
|
||||
for(var i=0; i<socketids.length; ++i) {
|
||||
var socketRooms = rooms.clientRooms(socketids[i]);
|
||||
if (Array.isArray(socketRooms)) {
|
||||
socketRooms.forEach(function(roomName) {
|
||||
if (roomName.startsWith('uid_')) {
|
||||
var uid = roomName.split('_')[1];
|
||||
if (uids.indexOf(uid) === -1) {
|
||||
uids.push(uid);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
callback(null, uids);
|
||||
return uids;
|
||||
callback(null, []);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -52,14 +52,6 @@ SocketMeta.rooms.enter = function(socket, data, callback) {
|
||||
if (data.enter) {
|
||||
rooms.enter(socket, data.enter);
|
||||
socket.currentRoom = data.enter;
|
||||
// if (data.enter.indexOf('topic') !== -1) {
|
||||
// data.uid = socket.uid;
|
||||
// data.picture = validator.escape(data.picture);
|
||||
// data.username = validator.escape(data.username);
|
||||
// data.userslug = validator.escape(data.userslug);
|
||||
|
||||
// websockets.in(data.enter).emit('event:user_enter', data);
|
||||
// }
|
||||
}
|
||||
callback();
|
||||
};
|
||||
@@ -75,9 +67,6 @@ SocketMeta.rooms.leaveCurrent = function(socket, data, callback) {
|
||||
function leaveCurrentRoom(socket) {
|
||||
if (socket.currentRoom) {
|
||||
rooms.leave(socket, socket.currentRoom);
|
||||
// if (socket.currentRoom.indexOf('topic') !== -1) {
|
||||
// websockets.in(socket.currentRoom).emit('event:user_leave', socket.uid);
|
||||
// }
|
||||
socket.currentRoom = '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,15 +63,14 @@ module.exports = function(SocketPosts) {
|
||||
|
||||
async.parallel({
|
||||
admins: async.apply(groups.getMembers, 'administrators', 0, -1),
|
||||
moderators: async.apply(groups.getMembers, 'cid:' + result.topic.cid + ':privileges:mods', 0, -1),
|
||||
uidsInTopic: async.apply(websockets.getUidsInRoom, 'topic_' + result.topic.tid)
|
||||
moderators: async.apply(groups.getMembers, 'cid:' + result.topic.cid + ':privileges:mods', 0, -1)
|
||||
}, function(err, results) {
|
||||
if (err) {
|
||||
return winston.error(err);
|
||||
}
|
||||
|
||||
var uids = results.uidsInTopic.filter(function(uid) {
|
||||
return (results.admins.indexOf(uid) !== -1 || results.moderators.indexOf(uid) !== -1) && parseInt(uid, 10) !== socket.uid;
|
||||
var uids = results.admins.concat(results.moderators).filter(function(uid, index, array) {
|
||||
return uid && array.indexOf(uid) === index;
|
||||
});
|
||||
|
||||
uids.forEach(function(uid) {
|
||||
|
||||
@@ -74,22 +74,6 @@ SocketTopics.post = function(socket, data, callback) {
|
||||
});
|
||||
};
|
||||
|
||||
SocketTopics.enter = function(socket, tid, callback) {
|
||||
if (!parseInt(tid, 10) || !socket.uid) {
|
||||
return;
|
||||
}
|
||||
async.parallel({
|
||||
markAsRead: function(next) {
|
||||
SocketTopics.markAsRead(socket, [tid], next);
|
||||
},
|
||||
users: function(next) {
|
||||
websockets.getUsersInRoom(socket.uid, 'topic_' + tid, 0, 9, next);
|
||||
}
|
||||
}, function(err, result) {
|
||||
callback(err, result ? result.users : null);
|
||||
});
|
||||
};
|
||||
|
||||
SocketTopics.postcount = function(socket, tid, callback) {
|
||||
topics.getTopicField(tid, 'postcount', callback);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user