Skip to content
Browse files

Fix for crash if connecting without an account.

  • Loading branch information...
1 parent 07c57f6 commit 39bce6f375eb2e7138fde87622c32635ec3f475b @ericbarch ericbarch committed Jul 3, 2012
Showing with 11 additions and 9 deletions.
  1. +11 −9 lib/socket.js
View
20 lib/socket.js
@@ -154,16 +154,18 @@ module.exports = function(socket, connections) {
});
socket.on('getOldMessages', function(data){
- Channel.find({name: data.channelName.toLowerCase(), server: connection.client.opt.server.toLowerCase(), user: current_user.username},
- {messages: {$slice: [data.skip, data.amount]}},
- function(err, results) {
- if(results){
- if(results[0]){
- results[0]['name'] = data.channelName.toLowerCase();
+ if (current_user) {
+ Channel.find({name: data.channelName.toLowerCase(), server: connection.client.opt.server.toLowerCase(), user: current_user.username},
+ {messages: {$slice: [data.skip, data.amount]}},
+ function(err, results) {
+ if(results){
+ if(results[0]){
+ results[0]['name'] = data.channelName.toLowerCase();
+ }
+ socket.emit('oldMessages', results[0]);
}
- socket.emit('oldMessages', results[0]);
- }
- });
+ });
+ }
});
});
}

0 comments on commit 39bce6f

Please sign in to comment.
Something went wrong with that request. Please try again.