mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +01:00
better handling of guest handles in frontend, #2569
This commit is contained in:
@@ -155,6 +155,7 @@ define('composer', [
|
||||
push({
|
||||
pid: pid,
|
||||
uid: threadData.uid,
|
||||
handle: threadData.handle,
|
||||
title: $('<div/>').html(threadData.title).text(),
|
||||
body: threadData.body,
|
||||
modified: false,
|
||||
@@ -228,7 +229,8 @@ define('composer', [
|
||||
allowTopicsThumbnail: allowTopicsThumbnail,
|
||||
showTags: isTopic || isMain,
|
||||
isTopic: isTopic,
|
||||
showHandleInput: (app.user.uid === 0 || (isEditing && isGuestPost && app.user.isAdmin)) && config.allowGuestHandles
|
||||
showHandleInput: (app.user.uid === 0 || (isEditing && isGuestPost && app.user.isAdmin)) && config.allowGuestHandles,
|
||||
handle: composer.posts[post_uuid] ? composer.posts[post_uuid].handle || '' : undefined
|
||||
};
|
||||
|
||||
parseAndTranslate(template, data, function(composerTemplate) {
|
||||
|
@@ -46,6 +46,7 @@ var winston = require('winston'),
|
||||
posts.setPostFields(data.pid, {
|
||||
edited: Date.now(),
|
||||
editor: data.uid,
|
||||
handle: data.handle,
|
||||
content: postData.content
|
||||
}, next);
|
||||
},
|
||||
|
@@ -35,7 +35,7 @@ SocketModules.composer.push = function(socket, pid, callback) {
|
||||
if (err || !canRead) {
|
||||
return callback(err || new Error('[[error:no-privileges]]'));
|
||||
}
|
||||
posts.getPostFields(pid, ['content', 'tid', 'uid'], function(err, postData) {
|
||||
posts.getPostFields(pid, ['content', 'tid', 'uid', 'handle'], function(err, postData) {
|
||||
if(err || (!postData && !postData.content)) {
|
||||
return callback(err || new Error('[[error:invalid-pid]]'));
|
||||
}
|
||||
@@ -62,6 +62,7 @@ SocketModules.composer.push = function(socket, pid, callback) {
|
||||
callback(null, {
|
||||
pid: pid,
|
||||
uid: postData.uid,
|
||||
handle: parseInt(meta.config.allowGuestHandles, 10) ? postData.handle : undefined,
|
||||
body: postData.content,
|
||||
title: results.topic.title,
|
||||
topic_thumb: results.topic.thumb,
|
||||
|
@@ -260,6 +260,7 @@ SocketPosts.edit = function(socket, data, callback) {
|
||||
// uid, pid, title, content, options
|
||||
postTools.edit({
|
||||
uid: socket.uid,
|
||||
handle: data.handle,
|
||||
pid: data.pid,
|
||||
title: data.title,
|
||||
content: data.content,
|
||||
@@ -274,6 +275,7 @@ SocketPosts.edit = function(socket, data, callback) {
|
||||
|
||||
websockets.in('topic_' + results.topic.tid).emit('event:post_edited', {
|
||||
pid: data.pid,
|
||||
handle: data.handle,
|
||||
title: results.topic.title,
|
||||
isMainPost: results.topic.isMainPost,
|
||||
tags: results.topic.tags,
|
||||
|
@@ -260,6 +260,11 @@ module.exports = function(Topics) {
|
||||
postData.user = results.userInfo[0];
|
||||
postData.topic = results.topicInfo;
|
||||
|
||||
// Username override for guests, if enabled
|
||||
if (parseInt(meta.config.allowGuestHandles, 10) === 1 && parseInt(postData.uid, 10) === 0 && data.handle) {
|
||||
postData.user.username = data.handle;
|
||||
}
|
||||
|
||||
if (results.settings.followTopicsOnReply) {
|
||||
threadTools.follow(postData.tid, uid);
|
||||
}
|
||||
|
Reference in New Issue
Block a user