|
|
|
@ -911,77 +911,6 @@ var utils = require('./../public/src/utils.js'),
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
User.active = {
|
|
|
|
|
get_record : function(socket) {
|
|
|
|
|
RDB.mget(['global:active_user_record', 'global:active_user_record_date'], function(err, data) {
|
|
|
|
|
RDB.handle(err);
|
|
|
|
|
socket.emit('api:user.active.get_record', { record: data[0], timestamp: data[1] });
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
get: function(callback) {
|
|
|
|
|
function user_record(total) {
|
|
|
|
|
RDB.get('global:active_user_record', function(err, record) {
|
|
|
|
|
RDB.handle(err);
|
|
|
|
|
|
|
|
|
|
if (total > record) {
|
|
|
|
|
RDB.set('global:active_user_record', total);
|
|
|
|
|
RDB.set('global:active_user_record_date', Date.now());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RDB.keys('active:*', function(err, active) {
|
|
|
|
|
RDB.handle(err);
|
|
|
|
|
|
|
|
|
|
var returnObj = {
|
|
|
|
|
users: 0,
|
|
|
|
|
anon: 0,
|
|
|
|
|
uids: []
|
|
|
|
|
},
|
|
|
|
|
keys = [];
|
|
|
|
|
|
|
|
|
|
if (active.length > 0) {
|
|
|
|
|
for(var a in active) {
|
|
|
|
|
keys.push('sess:' + active[a].split(':')[1] + ':uid');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RDB.mget(keys, function(err, uids) {
|
|
|
|
|
RDB.handle(err);
|
|
|
|
|
|
|
|
|
|
for(var u in uids) {
|
|
|
|
|
if (uids[u] !== null) {
|
|
|
|
|
if (returnObj.uids.indexOf(uids[u]) === -1) {
|
|
|
|
|
returnObj.users++;
|
|
|
|
|
returnObj.uids.push(uids[u]);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
returnObj.anon++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
user_record(returnObj.anon + returnObj.users);
|
|
|
|
|
|
|
|
|
|
if (callback === undefined) {
|
|
|
|
|
io.sockets.emit('api:user.active.get', returnObj)
|
|
|
|
|
} else {
|
|
|
|
|
callback(returnObj);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
io.sockets.emit('api:user.active.get', returnObj)
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
register: function(sessionID) {
|
|
|
|
|
// Active state persists for 10 minutes
|
|
|
|
|
var active_session = 'active:' + sessionID;
|
|
|
|
|
RDB.set(active_session, '');
|
|
|
|
|
RDB.expire(active_session, 60*10)
|
|
|
|
|
this.get();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
User.notifications = {
|
|
|
|
|
get: function(uid, callback) {
|
|
|
|
|
var maxNotifs = 15;
|
|
|
|
|