Node.js based forum software built for the modern web
better handling of guest handles in frontend, #2569
Julian Lam23b9b21cddcf
diff --git a/public/src/modules/composer.js b/public/src/modules/composer.jsindex a07af172f1..5a80616517 100644--- a/public/src/modules/composer.js+++ b/public/src/modules/composer.js@@ -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) {diff --git a/src/postTools.js b/src/postTools.jsindex c9e7648ea9..b157ead650 100644--- a/src/postTools.js+++ b/src/postTools.js@@ -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);},diff --git a/src/socket.io/modules.js b/src/socket.io/modules.jsindex 7c74530e3e..71a44f36bd 100644--- a/src/socket.io/modules.js+++ b/src/socket.io/modules.js@@ -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,diff --git a/src/socket.io/posts.js b/src/socket.io/posts.jsindex de66e6a5e3..97b8e7ea74 100644--- a/src/socket.io/posts.js+++ b/src/socket.io/posts.js@@ -260,6 +260,7 @@ SocketPosts.edit = function(socket, data, callback) {// uid, pid, title, content, optionspostTools.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,diff --git a/src/topics/create.js b/src/topics/create.jsindex 25053ef819..9fd7354b17 100644--- a/src/topics/create.js+++ b/src/topics/create.js@@ -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);}