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

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

@ -12,12 +12,21 @@ module.exports = function (Posts) {
Posts.getUserInfoForPosts = function (uids, uid, callback) {
var groupsMap = {};
var userData;
var userSettings;
async.waterfall([
function (next) {
async.parallel({
userData: function (next) {
user.getUsersFields(uids, ['uid', 'username', 'fullname', 'userslug', 'reputation', 'postcount', 'picture', 'signature', 'banned', 'status', 'lastonline', 'groupTitle'], next);
},
function (_userData, next) {
userData = _userData;
userSettings: function (next) {
user.getMultipleUserSettings(uids, next);
},
}, next);
},
function (results, next) {
userData = results.userData;
userSettings = results.userSettings;
var groupTitles = userData.map(function (userData) {
return userData && userData.groupTitle;
}).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.username = userData.username || '[[global:guest]]';
userData.userslug = userData.userslug || '';
@ -48,7 +57,7 @@ module.exports = function (Posts) {
userData.picture = userData.picture || '';
userData.status = user.getStatus(userData);
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) {
userData.fullname = undefined;
}

@ -115,6 +115,9 @@ Topics.getTopicsByTids = function (tids, uid, callback) {
users: function (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.getCategoriesFields(cids, ['cid', 'name', 'slug', 'icon', 'image', 'bgColor', 'color', 'disabled'], next);
},
@ -136,11 +139,11 @@ Topics.getTopicsByTids = function (tids, uid, callback) {
}, next);
},
function (results, next) {
if (parseInt(meta.config.hideFullname, 10) === 1) {
results.users.forEach(function (user) {
results.users.forEach(function (user, index) {
if (parseInt(meta.config.hideFullname, 10) === 1 || !results.userSettings[index].showfullname) {
user.fullname = undefined;
});
}
});
var users = _.zipObject(uids, results.users);
var categories = _.zipObject(cids, results.categories);

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

Loading…
Cancel
Save