|
|
@ -85,21 +85,19 @@ SocketModules.chats.send = function(socket, data, callback) {
|
|
|
|
socket.lastChatMessageTime = now;
|
|
|
|
socket.lastChatMessageTime = now;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Messaging.canMessageRoom(socket.uid, data.roomId, function(err, allowed, notAllowedMessage) {
|
|
|
|
async.waterfall([
|
|
|
|
if (err || !allowed) {
|
|
|
|
function (next) {
|
|
|
|
return callback(err || new Error(notAllowedMessage));
|
|
|
|
Messaging.canMessageRoom(socket.uid, data.roomId, next);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
function (next) {
|
|
|
|
Messaging.sendMessage(socket.uid, data.roomId, data.message, now, function(err, message) {
|
|
|
|
Messaging.sendMessage(socket.uid, data.roomId, data.message, now, next);
|
|
|
|
if (err) {
|
|
|
|
},
|
|
|
|
return callback(err);
|
|
|
|
function (message, next) {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Messaging.notifyUsersInRoom(socket.uid, data.roomId, message);
|
|
|
|
Messaging.notifyUsersInRoom(socket.uid, data.roomId, message);
|
|
|
|
|
|
|
|
user.updateOnlineUsers(socket.uid);
|
|
|
|
callback();
|
|
|
|
next();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
], callback);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
SocketModules.chats.loadRoom = function(socket, data, callback) {
|
|
|
|
SocketModules.chats.loadRoom = function(socket, data, callback) {
|
|
|
@ -217,12 +215,7 @@ SocketModules.chats.delete = function(socket, data, callback) {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
SocketModules.chats.canMessage = function(socket, roomId, callback) {
|
|
|
|
SocketModules.chats.canMessage = function(socket, roomId, callback) {
|
|
|
|
Messaging.canMessageRoom(socket.uid, roomId, function(err, allowed, notAllowedMessage) {
|
|
|
|
Messaging.canMessageRoom(socket.uid, roomId, callback);
|
|
|
|
if (err || !allowed) {
|
|
|
|
|
|
|
|
return callback(err || new Error(notAllowedMessage));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
callback();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
SocketModules.chats.markRead = function(socket, roomId, callback) {
|
|
|
|
SocketModules.chats.markRead = function(socket, roomId, callback) {
|
|
|
|