From 32d46f3889ff50f19acba46d2807a8332b7ba6a9 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Tue, 12 Aug 2014 11:41:18 -0400 Subject: [PATCH] crash fix --- src/socket.io/index.js | 8 ++++---- src/socket.io/user.js | 7 ++++--- src/user.js | 4 ---- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/socket.io/index.js b/src/socket.io/index.js index 299aee3933..f0d9ea40e6 100644 --- a/src/socket.io/index.js +++ b/src/socket.io/index.js @@ -93,8 +93,8 @@ Sockets.init = function(server) { uid: uid }); - socketUser.isOnline(socket, uid, function(err, data) { - socket.broadcast.emit('user.isOnline', err, data); + socketUser.isOnline(socket, [uid], function(err, data) { + socket.broadcast.emit('user.isOnline', err, data[0]); }); }); }); @@ -114,8 +114,8 @@ Sockets.init = function(server) { if (uid && Sockets.getUserSockets(uid).length <= 1) { db.sortedSetRemove('users:online', uid, function(err) { - socketUser.isOnline(socket, uid, function(err, data) { - socket.broadcast.emit('user.isOnline', err, data); + socketUser.isOnline(socket, [uid], function(err, data) { + socket.broadcast.emit('user.isOnline', err, data[0]); }); }); } diff --git a/src/socket.io/user.js b/src/socket.io/user.js index 06079dedaa..7501c9651b 100644 --- a/src/socket.io/user.js +++ b/src/socket.io/user.js @@ -227,6 +227,7 @@ SocketUser.getOnlineUsers = function(socket, uids, callback) { if (err) { return callback(err); } + userData.forEach(function(user) { if (user) { returnData[user.uid] = user; @@ -291,9 +292,9 @@ SocketUser.loadMore = function(socket, data, callback) { SocketUser.setStatus = function(socket, status, callback) { var server = require('./index'); user.setUserField(socket.uid, 'status', status, function(err) { - SocketUser.isOnline(socket, socket.uid, function(err, data) { - server.server.sockets.emit('user.isOnline', err, data); - callback(err, data); + SocketUser.isOnline(socket, [socket.uid], function(err, data) { + server.server.sockets.emit('user.isOnline', err, data[0]); + callback(err, data[0]); }); }); }; diff --git a/src/user.js b/src/user.js index 535bffa7b0..c0e96960c6 100644 --- a/src/user.js +++ b/src/user.js @@ -442,10 +442,6 @@ var bcrypt = require('bcryptjs'), return user; }); - if (uids.length === 1) { - userData = userData[0]; - } - callback(null, userData); }); };