diff --git a/node_modules/.DS_Store b/node_modules/.DS_Store new file mode 100644 index 0000000000..30153defb1 Binary files /dev/null and b/node_modules/.DS_Store differ diff --git a/node_modules/nodebb-theme-aawaa b/node_modules/nodebb-theme-aawaa new file mode 160000 index 0000000000..71a76ef823 --- /dev/null +++ b/node_modules/nodebb-theme-aawaa @@ -0,0 +1 @@ +Subproject commit 71a76ef8238a4194f13545fd86bd54a5ffd9bd75 diff --git a/public/src/modules/quickreply.js b/public/src/modules/quickreply.js index 55aea0b769..b78603e286 100644 --- a/public/src/modules/quickreply.js +++ b/public/src/modules/quickreply.js @@ -58,11 +58,17 @@ define('quickreply', [ } const replyMsg = components.get('topic/quickreply/text').val(); + const anonCheckbox = document.getElementById('anonymousCheckbox').checked ? 'true' : 'false'; + const replyData = { tid: ajaxify.data.tid, handle: undefined, content: replyMsg, + anon: anonCheckbox, }; + + console.log('Reply data being sent:', replyData); + const replyLen = replyMsg.length; if (replyLen < parseInt(config.minimumPostLength, 10)) { return alerts.error('[[error:content-too-short, ' + config.minimumPostLength + ']]'); diff --git a/src/api/helpers.js b/src/api/helpers.js index ef7c062482..ffe2b018f2 100644 --- a/src/api/helpers.js +++ b/src/api/helpers.js @@ -11,10 +11,14 @@ const websockets = require('../socket.io'); const events = require('../events'); exports.setDefaultPostData = function (reqOrSocket, data) { - data.uid = reqOrSocket.uid; - data.req = exports.buildReqObject(reqOrSocket, { ...data }); - data.timestamp = Date.now(); - data.fromQueue = false; + if (data.anon === 'true') { + data.uid = 100; // Set uid to 0 for anonymous posts + } else { + data.uid = reqOrSocket.uid; // Otherwise, use the uid from reqOrSocket + } + data.req = exports.buildReqObject(reqOrSocket, { ...data }); + data.timestamp = Date.now(); + data.fromQueue = false; }; // creates a slimmed down version of the request object diff --git a/src/api/topics.js b/src/api/topics.js index 7a6cabf966..ffc7b9aaa7 100644 --- a/src/api/topics.js +++ b/src/api/topics.js @@ -88,8 +88,17 @@ topicsAPI.reply = async function (caller, data) { throw new Error('[[error:invalid-data]]'); } const payload = { ...data }; - apiHelpers.setDefaultPostData(caller, payload); + if (data.anon === 'true') { + payload.username = 'Anonymous User'; + payload.userslug = null; + payload.uid = 100; + console.log('Anonymous post detected, making it anonymous'); + } + console.log('This is the payload', payload) + apiHelpers.setDefaultPostData(caller, payload); + console.log('Payload being sent to topics.reply:', payload); + await meta.blacklist.test(caller.ip); const shouldQueue = await posts.shouldQueue(caller.uid, payload); if (shouldQueue) { diff --git a/src/controllers/write/topics.js b/src/controllers/write/topics.js index b9691a8da5..1d1301c2b4 100644 --- a/src/controllers/write/topics.js +++ b/src/controllers/write/topics.js @@ -29,8 +29,20 @@ Topics.create = async (req, res) => { }; Topics.reply = async (req, res) => { - const id = await lockPosting(req, '[[error:already-posting]]'); - try { + const id = await lockPosting(req, '[[error:already-posting]]'); + try { + const isAnonymous = req.body.anon === 'true' || req.body.anon === 'on'; + console.log("Anonymous flag received:", isAnonymous); + let replyData = { ...req.body, tid: req.params.tid }; + if (isAnonymous) { + console.log("Post is anonymous. Modifying the username, userslug, and setting uid to 0."); + replyData.username = 'Anonymous User'; + replyData.userslug = null; + replyData.uid = 100; // Set uid to 100 to mark the post as anonymous + } else { + console.log("Post is not anonymous."); + } + console.log("Final reply data being sent:", replyData); const payload = await api.topics.reply(req, { ...req.body, tid: req.params.tid }); helpers.formatApiResponse(200, res, payload); } finally {