various group chat fixes #3980

fix multiple modals using the same tagsinput
fix online user getting chat notification
fix owner not being able to remove users in the chat modal
This commit is contained in:
barisusakli
2015-12-21 10:14:44 +02:00
parent 80fd0b20bd
commit dff3d7f20e
5 changed files with 45 additions and 29 deletions

View File

@@ -101,20 +101,27 @@ SocketModules.chats.send = function(socket, data, callback) {
});
};
SocketModules.chats.getUsersInRoom = function(socket, data, callback) {
SocketModules.chats.loadRoom = function(socket, data, callback) {
if (!data || !data.roomId) {
return callback(new Error('[[error:invalid-data]]'));
}
var isOwner = false;
async.waterfall([
function (next) {
Messaging.isUserInRoom(socket.uid, data.roomId, next);
async.parallel({
inRoom: async.apply(Messaging.isUserInRoom, socket.uid, data.roomId),
isOwner: async.apply(Messaging.isRoomOwner, socket.uid, data.roomId)
}, next);
},
function (inRoom, next) {
if (!inRoom) {
function (results, next) {
if (!results.inRoom) {
return next(new Error('[[error:not-allowerd]]'));
}
isOwner = results.isOwner;
Messaging.getUsersInRoom(data.roomId, 0, -1, next);
},
function (users, next) {
next(null, {users: users, owner: isOwner});
}
], callback);
};