fix: #8297 guest handles shown in category.tpl

v1.18.x
Julian Lam 5 years ago
parent 89d1764715
commit fcb81cb8ca

@ -120,7 +120,7 @@
"change_owner_instruction": "Click the posts you want to assign to another user", "change_owner_instruction": "Click the posts you want to assign to another user",
"composer.title_placeholder": "Enter your topic title here...", "composer.title_placeholder": "Enter your topic title here...",
"composer.handle_placeholder": "Name", "composer.handle_placeholder": "Enter your name/handle here",
"composer.discard": "Discard", "composer.discard": "Discard",
"composer.submit": "Submit", "composer.submit": "Submit",
"composer.replying_to": "Replying to %1", "composer.replying_to": "Replying to %1",

@ -69,7 +69,6 @@ Topics.getTopicsByTids = async function (tids, options) {
const [ const [
callerSettings, callerSettings,
users,
userSettings, userSettings,
categoriesData, categoriesData,
hasRead, hasRead,
@ -79,7 +78,6 @@ Topics.getTopicsByTids = async function (tids, options) {
tags, tags,
] = await Promise.all([ ] = await Promise.all([
user.getSettings(uid), user.getSettings(uid),
user.getUsersFields(uids, ['uid', 'username', 'fullname', 'userslug', 'reputation', 'postcount', 'picture', 'signature', 'banned', 'status']),
user.getMultipleUserSettings(uids), user.getMultipleUserSettings(uids),
categories.getCategoriesFields(cids, ['cid', 'name', 'slug', 'icon', 'image', 'imageClass', 'bgColor', 'color', 'disabled']), categories.getCategoriesFields(cids, ['cid', 'name', 'slug', 'icon', 'image', 'imageClass', 'bgColor', 'color', 'disabled']),
Topics.hasReadTopics(tids, uid), Topics.hasReadTopics(tids, uid),
@ -89,11 +87,21 @@ Topics.getTopicsByTids = async function (tids, options) {
Topics.getTopicsTagsObjects(tids), Topics.getTopicsTagsObjects(tids),
]); ]);
users.forEach(function (user, index) { let users = await user.getUsersFields(uids, ['uid', 'username', 'fullname', 'userslug', 'reputation', 'postcount', 'picture', 'signature', 'banned', 'status']);
if (meta.config.hideFullname || !userSettings[index].showfullname) { users = await Promise.all(users.map(async (userObj, idx) => {
user.fullname = undefined; // 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 usersMap = _.zipObject(uids, users);
const categoriesMap = _.zipObject(cids, categoriesData); const categoriesMap = _.zipObject(cids, categoriesData);

Loading…
Cancel
Save