Skip to content

Node.js based forum software built for the modern web

lint fixes

Baris Usakli27a6b8a7137d
diff --git a/public/src/client/chats.js b/public/src/client/chats.js
index 892a526602..293b1cb20d 100644
--- a/public/src/client/chats.js
+++ b/public/src/client/chats.js
@@ -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) {
diff --git a/src/controllers/accounts/chats.js b/src/controllers/accounts/chats.js
index e41d77c4ef..c3b9990c26 100644
--- a/src/controllers/accounts/chats.js
+++ b/src/controllers/accounts/chats.js
@@ -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;