mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 20:16:04 +01:00
cleanup and tests
This commit is contained in:
@@ -25,69 +25,67 @@ module.exports = function (Posts) {
|
||||
});
|
||||
groups.getGroupsData(groupTitles, next);
|
||||
},
|
||||
], function (err, groupsData) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
groupsData.forEach(function (group) {
|
||||
if (group && group.userTitleEnabled) {
|
||||
groupsMap[group.name] = {
|
||||
name: group.name,
|
||||
slug: group.slug,
|
||||
labelColor: group.labelColor,
|
||||
icon: group.icon,
|
||||
userTitle: group.userTitle,
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
userData.forEach(function (userData) {
|
||||
userData.uid = userData.uid || 0;
|
||||
userData.username = userData.username || '[[global:guest]]';
|
||||
userData.userslug = userData.userslug || '';
|
||||
userData.reputation = userData.reputation || 0;
|
||||
userData.postcount = userData.postcount || 0;
|
||||
userData.banned = parseInt(userData.banned, 10) === 1;
|
||||
userData.picture = userData.picture || '';
|
||||
userData.status = user.getStatus(userData);
|
||||
userData.signature = validator.escape(String(userData.signature || ''));
|
||||
userData.fullname = validator.escape(String(userData.fullname || ''));
|
||||
});
|
||||
|
||||
async.map(userData, function (userData, next) {
|
||||
async.parallel({
|
||||
isMemberOfGroup: function (next) {
|
||||
if (!userData.groupTitle || !groupsMap[userData.groupTitle]) {
|
||||
return next();
|
||||
}
|
||||
groups.isMember(userData.uid, userData.groupTitle, next);
|
||||
},
|
||||
signature: function (next) {
|
||||
if (!userData.signature || parseInt(meta.config.disableSignatures, 10) === 1) {
|
||||
userData.signature = '';
|
||||
return next();
|
||||
}
|
||||
Posts.parseSignature(userData, uid, next);
|
||||
},
|
||||
customProfileInfo: function (next) {
|
||||
plugins.fireHook('filter:posts.custom_profile_info', { profile: [], uid: userData.uid }, next);
|
||||
},
|
||||
}, function (err, results) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
function (groupsData, next) {
|
||||
groupsData.forEach(function (group) {
|
||||
if (group && group.userTitleEnabled) {
|
||||
groupsMap[group.name] = {
|
||||
name: group.name,
|
||||
slug: group.slug,
|
||||
labelColor: group.labelColor,
|
||||
icon: group.icon,
|
||||
userTitle: group.userTitle,
|
||||
};
|
||||
}
|
||||
|
||||
if (results.isMemberOfGroup && userData.groupTitle && groupsMap[userData.groupTitle]) {
|
||||
userData.selectedGroup = groupsMap[userData.groupTitle];
|
||||
}
|
||||
|
||||
userData.custom_profile_info = results.customProfileInfo.profile;
|
||||
|
||||
plugins.fireHook('filter:posts.modifyUserInfo', userData, next);
|
||||
});
|
||||
}, callback);
|
||||
});
|
||||
|
||||
userData.forEach(function (userData) {
|
||||
userData.uid = userData.uid || 0;
|
||||
userData.username = userData.username || '[[global:guest]]';
|
||||
userData.userslug = userData.userslug || '';
|
||||
userData.reputation = userData.reputation || 0;
|
||||
userData.postcount = userData.postcount || 0;
|
||||
userData.banned = parseInt(userData.banned, 10) === 1;
|
||||
userData.picture = userData.picture || '';
|
||||
userData.status = user.getStatus(userData);
|
||||
userData.signature = validator.escape(String(userData.signature || ''));
|
||||
userData.fullname = validator.escape(String(userData.fullname || ''));
|
||||
});
|
||||
|
||||
async.map(userData, function (userData, next) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
async.parallel({
|
||||
isMemberOfGroup: function (next) {
|
||||
if (!userData.groupTitle || !groupsMap[userData.groupTitle]) {
|
||||
return next();
|
||||
}
|
||||
groups.isMember(userData.uid, userData.groupTitle, next);
|
||||
},
|
||||
signature: function (next) {
|
||||
if (!userData.signature || parseInt(meta.config.disableSignatures, 10) === 1) {
|
||||
userData.signature = '';
|
||||
return next();
|
||||
}
|
||||
Posts.parseSignature(userData, uid, next);
|
||||
},
|
||||
customProfileInfo: function (next) {
|
||||
plugins.fireHook('filter:posts.custom_profile_info', { profile: [], uid: userData.uid }, next);
|
||||
},
|
||||
}, next);
|
||||
},
|
||||
function (results, next) {
|
||||
if (results.isMemberOfGroup && userData.groupTitle && groupsMap[userData.groupTitle]) {
|
||||
userData.selectedGroup = groupsMap[userData.groupTitle];
|
||||
}
|
||||
|
||||
userData.custom_profile_info = results.customProfileInfo.profile;
|
||||
|
||||
plugins.fireHook('filter:posts.modifyUserInfo', userData, next);
|
||||
},
|
||||
], next);
|
||||
}, next);
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
|
||||
Posts.isOwner = function (pid, uid, callback) {
|
||||
|
||||
Reference in New Issue
Block a user