v1.18.x
Baris Usakli 7 years ago
parent 500c978a26
commit 68bcfb2883

@ -82,6 +82,7 @@ module.exports = function (middleware) {
uid: 0, uid: 0,
username: '[[global:guest]]', username: '[[global:guest]]',
userslug: '', userslug: '',
fullname: '[[global:guest]]',
email: '', email: '',
picture: user.getDefaultAvatar(), picture: user.getDefaultAvatar(),
status: 'offline', status: 'offline',

@ -12,12 +12,21 @@ module.exports = function (Posts) {
Posts.getUserInfoForPosts = function (uids, uid, callback) { Posts.getUserInfoForPosts = function (uids, uid, callback) {
var groupsMap = {}; var groupsMap = {};
var userData; var userData;
var userSettings;
async.waterfall([ async.waterfall([
function (next) { function (next) {
async.parallel({
userData: function (next) {
user.getUsersFields(uids, ['uid', 'username', 'fullname', 'userslug', 'reputation', 'postcount', 'picture', 'signature', 'banned', 'status', 'lastonline', 'groupTitle'], next); user.getUsersFields(uids, ['uid', 'username', 'fullname', 'userslug', 'reputation', 'postcount', 'picture', 'signature', 'banned', 'status', 'lastonline', 'groupTitle'], next);
}, },
function (_userData, next) { userSettings: function (next) {
userData = _userData; user.getMultipleUserSettings(uids, next);
},
}, next);
},
function (results, next) {
userData = results.userData;
userSettings = results.userSettings;
var groupTitles = userData.map(function (userData) { var groupTitles = userData.map(function (userData) {
return userData && userData.groupTitle; return userData && userData.groupTitle;
}).filter(function (groupTitle, index, array) { }).filter(function (groupTitle, index, array) {
@ -38,7 +47,7 @@ module.exports = function (Posts) {
} }
}); });
userData.forEach(function (userData) { userData.forEach(function (userData, index) {
userData.uid = userData.uid || 0; userData.uid = userData.uid || 0;
userData.username = userData.username || '[[global:guest]]'; userData.username = userData.username || '[[global:guest]]';
userData.userslug = userData.userslug || ''; userData.userslug = userData.userslug || '';
@ -48,7 +57,7 @@ module.exports = function (Posts) {
userData.picture = userData.picture || ''; userData.picture = userData.picture || '';
userData.status = user.getStatus(userData); userData.status = user.getStatus(userData);
userData.signature = validator.escape(String(userData.signature || '')); userData.signature = validator.escape(String(userData.signature || ''));
userData.fullname = validator.escape(String(userData.fullname || '')); userData.fullname = userSettings[index].showfullname ? validator.escape(String(userData.fullname || '')) : undefined;
if (parseInt(meta.config.hideFullname, 10) === 1) { if (parseInt(meta.config.hideFullname, 10) === 1) {
userData.fullname = undefined; userData.fullname = undefined;
} }

@ -115,6 +115,9 @@ Topics.getTopicsByTids = function (tids, uid, callback) {
users: function (next) { users: function (next) {
user.getUsersFields(uids, ['uid', 'username', 'fullname', 'userslug', 'reputation', 'postcount', 'picture', 'signature', 'banned', 'status'], next); user.getUsersFields(uids, ['uid', 'username', 'fullname', 'userslug', 'reputation', 'postcount', 'picture', 'signature', 'banned', 'status'], next);
}, },
userSettings: function (next) {
user.getMultipleUserSettings(uids, next);
},
categories: function (next) { categories: function (next) {
categories.getCategoriesFields(cids, ['cid', 'name', 'slug', 'icon', 'image', 'bgColor', 'color', 'disabled'], next); categories.getCategoriesFields(cids, ['cid', 'name', 'slug', 'icon', 'image', 'bgColor', 'color', 'disabled'], next);
}, },
@ -136,11 +139,11 @@ Topics.getTopicsByTids = function (tids, uid, callback) {
}, next); }, next);
}, },
function (results, next) { function (results, next) {
if (parseInt(meta.config.hideFullname, 10) === 1) { results.users.forEach(function (user, index) {
results.users.forEach(function (user) { if (parseInt(meta.config.hideFullname, 10) === 1 || !results.userSettings[index].showfullname) {
user.fullname = undefined; user.fullname = undefined;
});
} }
});
var users = _.zipObject(uids, results.users); var users = _.zipObject(uids, results.users);
var categories = _.zipObject(cids, results.categories); var categories = _.zipObject(cids, results.categories);

@ -12,7 +12,7 @@ var pubsub = require('../pubsub');
var LRU = require('lru-cache'); var LRU = require('lru-cache');
var cache = LRU({ var cache = LRU({
max: 1000, max: 2000,
length: function () { return 1; }, length: function () { return 1; },
maxAge: 1000 * 60 * 60, maxAge: 1000 * 60 * 60,
}); });

Loading…
Cancel
Save