|
|
|
@ -2,6 +2,7 @@
|
|
|
|
|
|
|
|
|
|
var async = require('async');
|
|
|
|
|
var validator = require('validator');
|
|
|
|
|
var _ = require('lodash');
|
|
|
|
|
|
|
|
|
|
var user = require('../user');
|
|
|
|
|
var groups = require('../groups');
|
|
|
|
@ -15,11 +16,16 @@ module.exports = function (Posts) {
|
|
|
|
|
var userData;
|
|
|
|
|
var userSettings;
|
|
|
|
|
var canUseSignature;
|
|
|
|
|
var allowMultipleBadges = parseInt(meta.config.allowMultipleBadges, 10) === 1;
|
|
|
|
|
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);
|
|
|
|
|
user.getUsersFields(uids, [
|
|
|
|
|
'uid', 'username', 'fullname', 'userslug',
|
|
|
|
|
'reputation', 'postcount', 'picture', 'signature',
|
|
|
|
|
'banned', 'status', 'lastonline', 'groupTitle',
|
|
|
|
|
], next);
|
|
|
|
|
},
|
|
|
|
|
userSettings: function (next) {
|
|
|
|
|
user.getMultipleUserSettings(uids, next);
|
|
|
|
@ -34,10 +40,10 @@ module.exports = function (Posts) {
|
|
|
|
|
userSettings = results.userSettings;
|
|
|
|
|
canUseSignature = results.canUseSignature;
|
|
|
|
|
var groupTitles = userData.map(function (userData) {
|
|
|
|
|
return userData && userData.groupTitle;
|
|
|
|
|
}).filter(function (groupTitle, index, array) {
|
|
|
|
|
return groupTitle && array.indexOf(groupTitle) === index;
|
|
|
|
|
return userData && userData.groupTitleArray;
|
|
|
|
|
});
|
|
|
|
|
groupTitles = _.uniq(_.flatten(groupTitles));
|
|
|
|
|
|
|
|
|
|
groups.getGroupsData(groupTitles, next);
|
|
|
|
|
},
|
|
|
|
|
function (groupsData, next) {
|
|
|
|
@ -64,6 +70,8 @@ module.exports = function (Posts) {
|
|
|
|
|
userData.status = user.getStatus(userData);
|
|
|
|
|
userData.signature = validator.escape(String(userData.signature || ''));
|
|
|
|
|
userData.fullname = userSettings[index].showfullname ? validator.escape(String(userData.fullname || '')) : undefined;
|
|
|
|
|
userData.selectedGroups = [];
|
|
|
|
|
|
|
|
|
|
if (parseInt(meta.config.hideFullname, 10) === 1) {
|
|
|
|
|
userData.fullname = undefined;
|
|
|
|
|
}
|
|
|
|
@ -73,11 +81,11 @@ module.exports = function (Posts) {
|
|
|
|
|
async.waterfall([
|
|
|
|
|
function (next) {
|
|
|
|
|
async.parallel({
|
|
|
|
|
isMemberOfGroup: function (next) {
|
|
|
|
|
if (!userData.groupTitle || !groupsMap[userData.groupTitle]) {
|
|
|
|
|
isMemberOfGroups: function (next) {
|
|
|
|
|
if (!Array.isArray(userData.groupTitleArray) || !userData.groupTitleArray.length) {
|
|
|
|
|
return next();
|
|
|
|
|
}
|
|
|
|
|
groups.isMember(userData.uid, userData.groupTitle, next);
|
|
|
|
|
groups.isMemberOfGroups(userData.uid, userData.groupTitleArray, next);
|
|
|
|
|
},
|
|
|
|
|
signature: function (next) {
|
|
|
|
|
if (!userData.signature || !canUseSignature || parseInt(meta.config.disableSignatures, 10) === 1) {
|
|
|
|
@ -92,8 +100,12 @@ module.exports = function (Posts) {
|
|
|
|
|
}, next);
|
|
|
|
|
},
|
|
|
|
|
function (results, next) {
|
|
|
|
|
if (results.isMemberOfGroup && userData.groupTitle && groupsMap[userData.groupTitle]) {
|
|
|
|
|
userData.selectedGroup = groupsMap[userData.groupTitle];
|
|
|
|
|
if (results.isMemberOfGroups && userData.groupTitleArray) {
|
|
|
|
|
userData.groupTitleArray.forEach(function (userGroup, index) {
|
|
|
|
|
if (results.isMemberOfGroups[index] && groupsMap[userGroup]) {
|
|
|
|
|
userData.selectedGroups.push(groupsMap[userGroup]);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
userData.custom_profile_info = results.customProfileInfo.profile;
|
|
|
|
|