lint fixes

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

@ -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,10 +61,7 @@ chatsController.get = function (req, res, callback) {
}),
}, next);
},
], function (err, data) {
if (err) {
return callback(err);
}
function (data) {
var room = data.room;
room.messages = data.messages;
@ -90,7 +83,8 @@ chatsController.get = function (req, res, callback) {
room.showUserInput = !room.maximumUsersInChatRoom || room.maximumUsersInChatRoom > 2;
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);
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