From e884ff1f59b1850431c0f484880695df37d011f3 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Fri, 17 Jan 2014 12:55:38 -0500 Subject: [PATCH] modules fixes --- src/socket.io/modules.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/socket.io/modules.js b/src/socket.io/modules.js index f871ea7c70..22d8458e23 100644 --- a/src/socket.io/modules.js +++ b/src/socket.io/modules.js @@ -33,7 +33,11 @@ SocketModules.composer.push = function(socket, pid, callback) { }); } ], function(err, results) { - callback(err, { + if(err) { + return callback(err); + } + + callback(null, { title: results[1], pid: pid, body: results[0].content @@ -64,11 +68,17 @@ SocketModules.composer.editCheck = function(socket, pid, callback) { SocketModules.chats = {}; SocketModules.chats.get = function(socket, data, callback) { - var touid = data.touid; - Messaging.getMessages(socket.uid, touid, callback); + if(!data) { + return callback(new Error('invalid data')); + } + + Messaging.getMessages(socket.uid, data.touid, callback); }; SocketModules.chats.send = function(socket, data) { + if(!data) { + return callback(new Error('invalid data')); + } var touid = data.touid; if (touid === socket.uid || socket.uid === 0) {