changed addUserInfoToPost to add a user object

v1.18.x
barisusakli 11 years ago
parent e0911c1fff
commit bddc270033

@ -232,48 +232,47 @@ var db = require('./database'),
return callback(err); return callback(err);
} }
postTools.parseSignature(userData.signature, function(err, signature) { post.user = {
if(err) { username: userData.username || 'anonymous',
return callback(err); userslug: userData.userslug || '',
} reputation: userData.reputation || 0,
postcount: userData.postcount || 0,
post.username = userData.username || 'anonymous'; banned: parseInt(userData.banned, 10) === 1,
post.userslug = userData.userslug || ''; picture: userData.picture || gravatar.url('', {}, true)
post.user_rep = userData.reputation || 0; };
post.user_postcount = userData.postcount || 0;
post.user_banned = parseInt(userData.banned, 10) === 1;
post.picture = userData.picture || gravatar.url('', {}, true);
if(meta.config.disableSignatures === undefined || parseInt(meta.config.disableSignatures, 10) === 0) {
post.signature = signature;
}
for (var info in customUserInfo) { for (var info in customUserInfo) {
if (customUserInfo.hasOwnProperty(info)) { if (customUserInfo.hasOwnProperty(info)) {
post[info] = userData[info] || customUserInfo[info]; post.user[info] = userData[info] || customUserInfo[info];
} }
} }
plugins.fireHook('filter:posts.custom_profile_info', {profile: [], uid: post.uid, pid: post.pid}, function(err, profile_info) { async.parallel({
if(err) { signature: function(next) {
return callback(err); if (parseInt(meta.config.disableSignatures, 10) !== 1) {
return postTools.parseSignature(userData.signature, next);
} }
post.custom_profile_info = profile_info.profile; next();
},
if (post.editor !== '') { editor: function(next) {
user.getUserFields(post.editor, ['username', 'userslug'], function(err, editorData) { if (!post.editor) {
return next();
}
user.getUserFields(post.editor, ['username', 'userslug'], next);
},
customProfileInfo: function(next) {
plugins.fireHook('filter:posts.custom_profile_info', {profile: [], uid: post.uid, pid: post.pid}, next);
}
}, function(err, results) {
if (err) { if (err) {
return callback(err); return callback(err);
} }
post.editorname = editorData.username; post.user.signature = results.signature;
post.editorslug = editorData.userslug; post.editor = results.editor;
callback(null, post); post.custom_profile_info = results.profile;
});
} else {
callback(null, post); callback(null, post);
}
});
}); });
}); });
}; };

Loading…
Cancel
Save