v1.18.x
barisusakli 8 years ago
parent c935e6a77c
commit 2ac3f5e392

@ -27,7 +27,12 @@ module.exports = function(SocketUser) {
if (allowedStatus.indexOf(status) === -1) { if (allowedStatus.indexOf(status) === -1) {
return callback(new Error('[[error:invalid-user-status]]')); return callback(new Error('[[error:invalid-user-status]]'));
} }
user.setUserField(socket.uid, 'status', status, function(err) {
var data = {status: status};
if (status !== 'offline') {
data.lastonline = Date.now();
}
user.setUserFields(socket.uid, data, function(err) {
if (err) { if (err) {
return callback(err); return callback(err);
} }

@ -134,7 +134,7 @@ var utils = require('../public/src/utils');
}; };
User.getStatus = function(userData) { User.getStatus = function(userData) {
var isOnline = Date.now() - parseInt(userData.lastonline, 10) < 300000; var isOnline = (Date.now() - parseInt(userData.lastonline, 10)) < 300000;
return isOnline ? (userData.status || 'online') : 'offline'; return isOnline ? (userData.status || 'online') : 'offline';
}; };

Loading…
Cancel
Save