diff --git a/public/src/modules/helpers.common.js b/public/src/modules/helpers.common.js index d607d7e20f..123b5eccc6 100644 --- a/public/src/modules/helpers.common.js +++ b/public/src/modules/helpers.common.js @@ -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) { diff --git a/src/topics/posts.js b/src/topics/posts.js index 58ad3d20c9..438844d753 100644 --- a/src/topics/posts.js +++ b/src/topics/posts.js @@ -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) => {