mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: #7620, allow adding new fields into user objects for posts
This commit is contained in:
@@ -21,11 +21,7 @@ module.exports = function (Posts) {
|
||||
function (next) {
|
||||
async.parallel({
|
||||
userData: function (next) {
|
||||
user.getUsersFields(uids, [
|
||||
'uid', 'username', 'fullname', 'userslug',
|
||||
'reputation', 'postcount', 'picture', 'signature',
|
||||
'banned', 'banned:expire', 'status', 'lastonline', 'groupTitle',
|
||||
], next);
|
||||
getUserData(uids, uid, next);
|
||||
},
|
||||
userSettings: function (next) {
|
||||
user.getMultipleUserSettings(uids, next);
|
||||
@@ -119,6 +115,27 @@ module.exports = function (Posts) {
|
||||
], callback);
|
||||
};
|
||||
|
||||
function getUserData(uids, uid, callback) {
|
||||
const fields = [
|
||||
'uid', 'username', 'fullname', 'userslug',
|
||||
'reputation', 'postcount', 'topiccount', 'picture',
|
||||
'signature', 'banned', 'banned:expire', 'status',
|
||||
'lastonline', 'groupTitle',
|
||||
];
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
plugins.fireHook('filter:posts.addUserFields', {
|
||||
fields: fields,
|
||||
uid: uid,
|
||||
uids: uids,
|
||||
}, next);
|
||||
},
|
||||
function (result, next) {
|
||||
user.getUsersFields(result.uids, _.uniq(result.fields), next);
|
||||
},
|
||||
], callback);
|
||||
}
|
||||
|
||||
Posts.isOwner = function (pid, uid, callback) {
|
||||
uid = parseInt(uid, 10);
|
||||
if (Array.isArray(pid)) {
|
||||
|
||||
Reference in New Issue
Block a user