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) {
|
function (next) {
|
||||||
async.parallel({
|
async.parallel({
|
||||||
userData: function (next) {
|
userData: function (next) {
|
||||||
user.getUsersFields(uids, [
|
getUserData(uids, uid, next);
|
||||||
'uid', 'username', 'fullname', 'userslug',
|
|
||||||
'reputation', 'postcount', 'picture', 'signature',
|
|
||||||
'banned', 'banned:expire', 'status', 'lastonline', 'groupTitle',
|
|
||||||
], next);
|
|
||||||
},
|
},
|
||||||
userSettings: function (next) {
|
userSettings: function (next) {
|
||||||
user.getMultipleUserSettings(uids, next);
|
user.getMultipleUserSettings(uids, next);
|
||||||
@@ -119,6 +115,27 @@ module.exports = function (Posts) {
|
|||||||
], callback);
|
], 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) {
|
Posts.isOwner = function (pid, uid, callback) {
|
||||||
uid = parseInt(uid, 10);
|
uid = parseInt(uid, 10);
|
||||||
if (Array.isArray(pid)) {
|
if (Array.isArray(pid)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user