add displayname to parent posts

isekai-main
Barış Soner Uşaklı 2 years ago
parent e8b40b5884
commit f2152953cd

@ -327,11 +327,11 @@ module.exports = function (utils, Benchpress, relative_path) {
}
function generateRepliedTo(post, timeagoCutoff) {
const username = post.parent && post.parent.username ?
post.parent.username : '[[global:guest]]';
const displayname = post.parent && post.parent.displayname ?
post.parent.displayname : '[[global:guest]]';
const isBeforeCutoff = post.timestamp < (Date.now() - (timeagoCutoff * oneDayInMs));
const langSuffix = isBeforeCutoff ? 'on' : 'ago';
return `[[topic:replied-to-user-${langSuffix}, ${post.toPid}, ${relative_path}/post/${post.toPid}, ${username}, ${relative_path}/post/${post.pid}, ${post.timestampISO}]]`;
return `[[topic:replied-to-user-${langSuffix}, ${post.toPid}, ${relative_path}/post/${post.toPid}, ${displayname}, ${relative_path}/post/${post.pid}, ${post.timestampISO}]]`;
}
function generateWrote(post, timeagoCutoff) {

@ -186,13 +186,13 @@ module.exports = function (Topics) {
const parentUids = _.uniq(parentPosts.map(postObj => postObj && postObj.uid));
const userData = await user.getUsersFields(parentUids, ['username']);
const usersMap = {};
userData.forEach((user) => {
usersMap[user.uid] = user.username;
});
const usersMap = _.zipObject(parentUids, userData);
const parents = {};
parentPosts.forEach((post, i) => {
parents[parentPids[i]] = { username: usersMap[post.uid] };
parents[parentPids[i]] = {
username: usersMap[post.uid].username,
displayname: usersMap[post.uid].displayname,
};
});
postData.forEach((post) => {

Loading…
Cancel
Save