Skip to content

Node.js based forum software built for the modern web

fix: #8297 guest handles shown in category.tpl

Julian Lamfcb81cb8ca9f
diff --git a/public/language/en-GB/topic.json b/public/language/en-GB/topic.json
index d4a547d6f8..5fb113f8d4 100644
--- a/public/language/en-GB/topic.json
+++ b/public/language/en-GB/topic.json
@@ -120,7 +120,7 @@
"change_owner_instruction": "Click the posts you want to assign to another user",
"composer.title_placeholder": "Enter your topic title here...",
- "composer.handle_placeholder": "Name",
+ "composer.handle_placeholder": "Enter your name/handle here",
"composer.discard": "Discard",
"composer.submit": "Submit",
"composer.replying_to": "Replying to %1",
diff --git a/src/topics/index.js b/src/topics/index.js
index 42c25190ac..9d072d8e00 100644
--- a/src/topics/index.js
+++ b/src/topics/index.js
@@ -69,7 +69,6 @@ Topics.getTopicsByTids = async function (tids, options) {
const [
callerSettings,
- users,
userSettings,
categoriesData,
hasRead,
@@ -79,7 +78,6 @@ Topics.getTopicsByTids = async function (tids, options) {
tags,
] = await Promise.all([
user.getSettings(uid),
- user.getUsersFields(uids, ['uid', 'username', 'fullname', 'userslug', 'reputation', 'postcount', 'picture', 'signature', 'banned', 'status']),
user.getMultipleUserSettings(uids),
categories.getCategoriesFields(cids, ['cid', 'name', 'slug', 'icon', 'image', 'imageClass', 'bgColor', 'color', 'disabled']),
Topics.hasReadTopics(tids, uid),
@@ -89,11 +87,21 @@ Topics.getTopicsByTids = async function (tids, options) {
Topics.getTopicsTagsObjects(tids),
]);
- users.forEach(function (user, index) {
- if (meta.config.hideFullname || !userSettings[index].showfullname) {
- user.fullname = undefined;
+ let users = await user.getUsersFields(uids, ['uid', 'username', 'fullname', 'userslug', 'reputation', 'postcount', 'picture', 'signature', 'banned', 'status']);
+ users = await Promise.all(users.map(async (userObj, idx) => {
+ // Retrieve guest handle from post
+ if (userObj.uid === 0) {
+ const handle = await posts.getPostField(topics[idx].mainPid, 'handle');
+ userObj.username = handle;
}
- });
+
+ // Hide fullname if needed
+ if (meta.config.hideFullname || !userSettings[idx].showfullname) {
+ userObj.fullname = undefined;
+ }
+
+ return userObj;
+ }));
const usersMap = _.zipObject(uids, users);
const categoriesMap = _.zipObject(cids, categoriesData);