mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-26 16:41:21 +01:00
feat: #11431
add joindate/postcount/reputation to user add lastposttime to topic
This commit is contained in:
@@ -74,6 +74,7 @@
|
|||||||
"posts": "Posts",
|
"posts": "Posts",
|
||||||
"x-posts": "<span class=\"formatted-number\">%1</span> posts",
|
"x-posts": "<span class=\"formatted-number\">%1</span> posts",
|
||||||
"x-topics": "<span class=\"formatted-number\">%1</span> topics",
|
"x-topics": "<span class=\"formatted-number\">%1</span> topics",
|
||||||
|
"x-reputation": "<span class=\"formatted-number\">%1</span> reputation",
|
||||||
"best": "Best",
|
"best": "Best",
|
||||||
"controversial": "Controversial",
|
"controversial": "Controversial",
|
||||||
"votes": "Votes",
|
"votes": "Votes",
|
||||||
|
|||||||
@@ -32,7 +32,9 @@ module.exports = function (Posts) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
const uids = postData.map(data => data && data.uid);
|
const uids = postData.map(data => data && data.uid);
|
||||||
const userData = await user.getUsersFields(uids, ['username', 'userslug', 'picture']);
|
const userData = await user.getUsersFields(uids, [
|
||||||
|
'username', 'userslug', 'picture', 'joindate', 'postcount', 'reputation',
|
||||||
|
]);
|
||||||
postData.forEach((postData, index) => {
|
postData.forEach((postData, index) => {
|
||||||
if (postData) {
|
if (postData) {
|
||||||
postData.user = userData[index];
|
postData.user = userData[index];
|
||||||
@@ -46,7 +48,7 @@ module.exports = function (Posts) {
|
|||||||
postData = postData.filter(p => p.id === filter.id);
|
postData = postData.filter(p => p.id === filter.id);
|
||||||
}
|
}
|
||||||
if (options.metadata) {
|
if (options.metadata) {
|
||||||
await Promise.all(postData.map(p => addMetaData(p)));
|
await Promise.all(postData.map(addMetaData));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter by tid if present
|
// Filter by tid if present
|
||||||
@@ -71,7 +73,7 @@ module.exports = function (Posts) {
|
|||||||
if (postData.data.cid) {
|
if (postData.data.cid) {
|
||||||
postData.topic = { cid: parseInt(postData.data.cid, 10) };
|
postData.topic = { cid: parseInt(postData.data.cid, 10) };
|
||||||
} else if (postData.data.tid) {
|
} else if (postData.data.tid) {
|
||||||
postData.topic = await topics.getTopicFields(postData.data.tid, ['title', 'cid']);
|
postData.topic = await topics.getTopicFields(postData.data.tid, ['title', 'cid', 'lastposttime']);
|
||||||
}
|
}
|
||||||
postData.category = await categories.getCategoryData(postData.topic.cid);
|
postData.category = await categories.getCategoryData(postData.topic.cid);
|
||||||
const result = await plugins.hooks.fire('filter:parse.post', { postData: postData.data });
|
const result = await plugins.hooks.fire('filter:parse.post', { postData: postData.data });
|
||||||
|
|||||||
Reference in New Issue
Block a user