fix: #7620, allow adding new fields into user objects for posts

v1.18.x
Barış Soner Uşaklı 6 years ago
parent 7ba4a864fd
commit a8e6520559

@ -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)) {

Loading…
Cancel
Save