Merge branch 'master' of github.com:greynaert/NodeBB into greynaert-master

v1.18.x
Julian Lam 11 years ago
commit 054fd46924

@ -494,35 +494,42 @@ var fs = require('fs'),
var websockets = require('../socket.io'); var websockets = require('../socket.io');
user.getUsers('users:online', 0, 49, function (err, data) { user.getUsers('users:online', 0, 49, function (err, data) {
var onlineUsers = []; var onlineUsers = [];
data = data.filter(function(item) { uid = 0;
return item.status !== 'offline'; if (req.user) {
}); uid = req.user.uid;
}
function iterator(userData, next) { user.isAdministrator(uid, function (err, isAdministrator) {
var online = websockets.isUserOnline(userData.uid); if (true != isAdministrator) {
if(!online) { data = data.filter(function(item) {
db.sortedSetRemove('users:online', userData.uid); return item.status !== 'offline';
return next(null); });
} }
onlineUsers.push(userData); function iterator(userData, next) {
next(null); var online = websockets.isUserOnline(userData.uid);
} if(!online) {
db.sortedSetRemove('users:online', userData.uid);
var anonymousUserCount = websockets.getOnlineAnonCount(); return next(null);
}
async.each(data, iterator, function(err) {
res.json({ onlineUsers.push(userData);
search_display: 'none', next(null);
loadmore_display: 'block', }
users: onlineUsers,
anonymousUserCount: anonymousUserCount, var anonymousUserCount = websockets.getOnlineAnonCount();
show_anon: anonymousUserCount?'':'hide'
}); async.each(data, iterator, function(err) {
}); res.json({
search_display: 'none',
loadmore_display: 'block',
users: onlineUsers,
anonymousUserCount: anonymousUserCount,
show_anon: anonymousUserCount?'':'hide'
});
});
});
}); });
} }

Loading…
Cancel
Save