|
|
@ -27,7 +27,6 @@ chatsController.get = function (req, res, callback) {
|
|
|
|
if (!uid) {
|
|
|
|
if (!uid) {
|
|
|
|
return callback();
|
|
|
|
return callback();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
privileges.global.can('chat', req.uid, next);
|
|
|
|
privileges.global.can('chat', req.uid, next);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
function (canChat, next) {
|
|
|
|
function (canChat, next) {
|
|
|
@ -51,48 +50,17 @@ chatsController.get = function (req, res, callback) {
|
|
|
|
title: '[[pages:chats]]',
|
|
|
|
title: '[[pages:chats]]',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
messaging.isUserInRoom(req.uid, req.params.roomid, next);
|
|
|
|
messaging.loadRoom(req.uid, { uid: uid, roomId: req.params.roomid }, next);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
function (inRoom, next) {
|
|
|
|
function (room) {
|
|
|
|
if (!inRoom) {
|
|
|
|
if (!room) {
|
|
|
|
return callback();
|
|
|
|
return callback();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
async.parallel({
|
|
|
|
|
|
|
|
users: async.apply(messaging.getUsersInRoom, req.params.roomid, 0, -1),
|
|
|
|
|
|
|
|
canReply: async.apply(messaging.canReply, req.params.roomid, req.uid),
|
|
|
|
|
|
|
|
room: async.apply(messaging.getRoomData, req.params.roomid),
|
|
|
|
|
|
|
|
messages: async.apply(messaging.getMessages, {
|
|
|
|
|
|
|
|
callerUid: req.uid,
|
|
|
|
|
|
|
|
uid: uid,
|
|
|
|
|
|
|
|
roomId: req.params.roomid,
|
|
|
|
|
|
|
|
isNew: false,
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
isAdminOrGlobalMod: function (next) {
|
|
|
|
|
|
|
|
user.isAdminOrGlobalMod(req.uid, next);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
}, next);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
function (data) {
|
|
|
|
|
|
|
|
var room = data.room;
|
|
|
|
|
|
|
|
room.messages = data.messages;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
room.isOwner = parseInt(room.owner, 10) === parseInt(req.uid, 10);
|
|
|
|
|
|
|
|
room.users = data.users.filter(function (user) {
|
|
|
|
|
|
|
|
return user && parseInt(user.uid, 10) && parseInt(user.uid, 10) !== req.uid;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
room.canReply = data.canReply;
|
|
|
|
|
|
|
|
room.groupChat = room.hasOwnProperty('groupChat') ? room.groupChat : room.users.length > 2;
|
|
|
|
|
|
|
|
room.rooms = recentChats.rooms;
|
|
|
|
room.rooms = recentChats.rooms;
|
|
|
|
room.uid = uid;
|
|
|
|
|
|
|
|
room.userslug = req.params.userslug;
|
|
|
|
|
|
|
|
room.nextStart = recentChats.nextStart;
|
|
|
|
room.nextStart = recentChats.nextStart;
|
|
|
|
room.usernames = messaging.generateUsernames(room.users, req.uid);
|
|
|
|
|
|
|
|
room.title = room.roomName || room.usernames || '[[pages:chats]]';
|
|
|
|
room.title = room.roomName || room.usernames || '[[pages:chats]]';
|
|
|
|
room.maximumUsersInChatRoom = parseInt(meta.config.maximumUsersInChatRoom, 10) || 0;
|
|
|
|
room.uid = uid;
|
|
|
|
room.maximumChatMessageLength = parseInt(meta.config.maximumChatMessageLength, 10) || 1000;
|
|
|
|
room.userslug = req.params.userslug;
|
|
|
|
room.showUserInput = !room.maximumUsersInChatRoom || room.maximumUsersInChatRoom > 2;
|
|
|
|
|
|
|
|
room.isAdminOrGlobalMod = data.isAdminOrGlobalMod;
|
|
|
|
|
|
|
|
res.render('chats', room);
|
|
|
|
res.render('chats', room);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
], callback);
|
|
|
|
], callback);
|
|
|
|