lint fixes

v1.18.x
Baris Usakli 8 years ago
parent bc6b1a8f56
commit 27a6b8a713

@ -22,7 +22,7 @@ define('forum/chats', [
Chats.addSocketListeners();
Chats.addGlobalEventListeners();
}
recentChats.init();
Chats.addEventListeners();
@ -315,7 +315,7 @@ define('forum/chats', [
fetch(config.relative_path + '/api/' + url, { credentials: 'include' })
.then(function (response) {
if (response.ok) {
response.json().then(function(payload) {
response.json().then(function (payload) {
app.parseAndTranslate('partials/chats/message-window', payload, function (html) {
components.get('chat/main-wrapper').html(html);
Chats.resizeMainWindow();
@ -331,7 +331,7 @@ define('forum/chats', [
});
});
} else {
console.warn('[search] Received ' + response.status +', query: ' + query);
console.warn('[search] Received ' + response.status);
}
})
.catch(function (error) {

@ -7,26 +7,22 @@ var meta = require('../../meta');
var user = require('../../user');
var helpers = require('../helpers');
var chatsController = {};
var chatsController = module.exports;
chatsController.get = function (req, res, callback) {
if (parseInt(meta.config.disableChat, 10) === 1) {
return callback();
}
var uid;
var username;
var recentChats;
async.waterfall([
function (next) {
async.parallel({
uid: async.apply(user.getUidByUserslug, req.params.userslug),
username: async.apply(user.getUsernameByUserslug, req.params.userslug),
}, next);
user.getUidByUserslug(req.params.userslug, next);
},
function (results, next) {
uid = results.uid;
username = results.username;
function (_uid, next) {
uid = _uid;
if (!uid) {
return callback();
}
@ -65,32 +61,30 @@ chatsController.get = function (req, res, callback) {
}),
}, next);
},
], function (err, data) {
if (err) {
return callback(err);
}
var room = data.room;
room.messages = data.messages;
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.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.uid = uid;
room.userslug = req.params.userslug;
room.nextStart = recentChats.nextStart;
room.usernames = messaging.generateUsernames(room.users, req.uid);
room.title = room.roomName || room.usernames || '[[pages:chats]]';
room.maximumUsersInChatRoom = parseInt(meta.config.maximumUsersInChatRoom, 10) || 0;
room.maximumChatMessageLength = parseInt(meta.config.maximumChatMessageLength, 10) || 1000;
room.showUserInput = !room.maximumUsersInChatRoom || room.maximumUsersInChatRoom > 2;
room.canReply = data.canReply;
room.groupChat = room.hasOwnProperty('groupChat') ? room.groupChat : room.users.length > 2;
room.rooms = recentChats.rooms;
room.uid = uid;
room.userslug = req.params.userslug;
room.nextStart = recentChats.nextStart;
room.usernames = messaging.generateUsernames(room.users, req.uid);
room.title = room.roomName || room.usernames || '[[pages:chats]]';
room.maximumUsersInChatRoom = parseInt(meta.config.maximumUsersInChatRoom, 10) || 0;
room.maximumChatMessageLength = parseInt(meta.config.maximumChatMessageLength, 10) || 1000;
room.showUserInput = !room.maximumUsersInChatRoom || room.maximumUsersInChatRoom > 2;
res.render('chats', room);
});
res.render('chats', room);
},
], callback);
};
chatsController.redirectToChat = function (req, res, next) {
@ -98,14 +92,15 @@ chatsController.redirectToChat = function (req, res, next) {
if (!req.uid) {
return next();
}
user.getUserField(req.uid, 'userslug', function (err, userslug) {
if (err || !userslug) {
return next(err);
}
helpers.redirect(res, '/user/' + userslug + '/chats' + (roomid ? '/' + roomid : ''));
});
async.waterfall([
function (next) {
user.getUserField(req.uid, 'userslug', next);
},
function (userslug, next) {
if (!userslug) {
return next();
}
helpers.redirect(res, '/user/' + userslug + '/chats' + (roomid ? '/' + roomid : ''));
},
], next);
};
module.exports = chatsController;

Loading…
Cancel
Save