only allow users in the room to get raw message content

This commit is contained in:
barisusakli
2015-12-17 11:22:15 +02:00
parent f4e502c793
commit f71fd0a3ec
3 changed files with 17 additions and 8 deletions

View File

@@ -31,11 +31,20 @@ SocketModules.chats.get = function(socket, data, callback) {
};
SocketModules.chats.getRaw = function(socket, data, callback) {
if(!data || !data.hasOwnProperty('mid')) {
if (!data || !data.hasOwnProperty('mid')) {
return callback(new Error('[[error:invalid-data]]'));
}
Messaging.getMessageField(data.mid, 'content', callback);
async.waterfall([
function (next) {
Messaging.isUserInRoom(socket.uid, data.roomId, next);
},
function (inRoom, next) {
if (!inRoom) {
return next(new Error('[[error:not-allowed]]'));
}
Messaging.getMessageField(data.mid, 'content', next);
}
], callback);
};
SocketModules.chats.newRoom = function(socket, data, callback) {