mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: guest handles to user displayname as well
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
var _ = require('lodash');
|
||||
const validator = require('validator');
|
||||
|
||||
var db = require('../database');
|
||||
var posts = require('../posts');
|
||||
@@ -111,9 +112,10 @@ Topics.getTopicsByTids = async function (tids, options) {
|
||||
result.topics.forEach(function (topic, i) {
|
||||
if (topic) {
|
||||
topic.category = result.categoriesMap[topic.cid];
|
||||
topic.user = result.usersMap[topic.uid];
|
||||
topic.user = topic.uid ? result.usersMap[topic.uid] : { ...result.usersMap[topic.uid] };
|
||||
if (result.tidToGuestHandle[topic.tid]) {
|
||||
topic.user.username = result.tidToGuestHandle[topic.tid];
|
||||
topic.user.username = validator.escape(result.tidToGuestHandle[topic.tid]);
|
||||
topic.user.displayname = topic.user.username;
|
||||
}
|
||||
topic.teaser = result.teasers[i] || null;
|
||||
topic.tags = tags[i];
|
||||
|
||||
@@ -68,6 +68,7 @@ module.exports = function (Topics) {
|
||||
// Username override for guests, if enabled
|
||||
if (meta.config.allowGuestHandles && postObj.uid === 0 && postObj.handle) {
|
||||
postObj.user.username = validator.escape(String(postObj.handle));
|
||||
postObj.user.displayname = postObj.user.username;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user