From 70a529ff801f2797a786a697b9db0817bf4b6133 Mon Sep 17 00:00:00 2001 From: Driftedboat Date: Mon, 23 Sep 2024 00:58:34 -0400 Subject: [PATCH] add anonymous field in creation and data fetch (backend) --- .../package.json | 67 +++++++++++++------ .../partials/composer-title-container.tpl | 4 -- src/posts/create.js | 1 + src/posts/data.js | 16 ++++- 4 files changed, 61 insertions(+), 27 deletions(-) diff --git a/node_modules/nodebb-plugin-composer-default/package.json b/node_modules/nodebb-plugin-composer-default/package.json index 625184980c..9265f64ae3 100644 --- a/node_modules/nodebb-plugin-composer-default/package.json +++ b/node_modules/nodebb-plugin-composer-default/package.json @@ -1,33 +1,35 @@ { - "name": "nodebb-plugin-composer-default", - "version": "10.2.36", - "description": "Default composer for NodeBB", - "main": "library.js", - "repository": { - "type": "git", - "url": "https://github.com/NodeBB/nodebb-plugin-composer-default" + "_from": "nodebb-plugin-composer-default@10.2.36", + "_id": "nodebb-plugin-composer-default@10.2.36", + "_inBundle": false, + "_integrity": "sha512-jeH56nebRJwvzh5df82VjYsGPVHZjImPDQO0Y6ZyI8Ll5wwxIWhHo5zny2DCw3IPDfgmrPYpa9N1Qpb+vkirHw==", + "_location": "/nodebb-plugin-composer-default", + "_phantomChildren": {}, + "_requested": { + "type": "version", + "registry": true, + "raw": "nodebb-plugin-composer-default@10.2.36", + "name": "nodebb-plugin-composer-default", + "escapedName": "nodebb-plugin-composer-default", + "rawSpec": "10.2.36", + "saveSpec": null, + "fetchSpec": "10.2.36" }, - "scripts": { - "lint": "eslint ." - }, - "keywords": [ - "nodebb", - "plugin", - "composer", - "markdown" + "_requiredBy": [ + "/" ], + "_resolved": "https://registry.npmjs.org/nodebb-plugin-composer-default/-/nodebb-plugin-composer-default-10.2.36.tgz", + "_shasum": "8106a4a249b7bfbb50f2c3d4b5533c3baca05aee", + "_spec": "nodebb-plugin-composer-default@10.2.36", + "_where": "/home/kris/nodebb-f24-bluesleep", "author": { "name": "NodeBB Team", "email": "sales@nodebb.org" }, - "license": "MIT", "bugs": { "url": "https://github.com/NodeBB/nodebb-plugin-composer-default/issues" }, - "readmeFilename": "README.md", - "nbbpm": { - "compatibility": "^3.0.0" - }, + "bundleDependencies": false, "dependencies": { "@textcomplete/contenteditable": "^0.1.12", "@textcomplete/core": "^0.1.12", @@ -35,9 +37,32 @@ "screenfull": "^5.0.2", "validator": "^13.7.0" }, + "deprecated": false, + "description": "Default composer for NodeBB", "devDependencies": { "eslint": "^7.32.0", "eslint-config-nodebb": "^0.0.1", "eslint-plugin-import": "^2.23.4" - } + }, + "homepage": "https://github.com/NodeBB/nodebb-plugin-composer-default#readme", + "keywords": [ + "nodebb", + "plugin", + "composer", + "markdown" + ], + "license": "MIT", + "main": "library.js", + "name": "nodebb-plugin-composer-default", + "nbbpm": { + "compatibility": "^3.0.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/NodeBB/nodebb-plugin-composer-default.git" + }, + "scripts": { + "lint": "eslint ." + }, + "version": "10.2.36" } diff --git a/node_modules/nodebb-plugin-composer-default/static/templates/partials/composer-title-container.tpl b/node_modules/nodebb-plugin-composer-default/static/templates/partials/composer-title-container.tpl index b46ea269a2..185393f285 100644 --- a/node_modules/nodebb-plugin-composer-default/static/templates/partials/composer-title-container.tpl +++ b/node_modules/nodebb-plugin-composer-default/static/templates/partials/composer-title-container.tpl @@ -24,10 +24,6 @@
-
- - -
diff --git a/src/posts/create.js b/src/posts/create.js index d541564c2e..c125a194bd 100644 --- a/src/posts/create.js +++ b/src/posts/create.js @@ -35,6 +35,7 @@ module.exports = function (Posts) { tid: tid, content: content, timestamp: timestamp, + anonymous: data.anonymous ? 1 : 0, // Added anonymous status }; if (data.toPid) { diff --git a/src/posts/data.js b/src/posts/data.js index 3a4d303ff5..bc836db8a3 100644 --- a/src/posts/data.js +++ b/src/posts/data.js @@ -22,13 +22,25 @@ module.exports = function (Posts) { posts: postData, fields: fields, }); - result.posts.forEach(post => modifyPost(post, fields)); + result.posts.forEach(post => { + modifyPost(post, fields); + if (post.anonymous ==1){ + post.uid = null; + } + }); return result.posts; }; Posts.getPostData = async function (pid) { const posts = await Posts.getPostsFields([pid], []); - return posts && posts.length ? posts[0] : null; + if (posts && posts.length) { + const post = posts[0]; + if (post.anonymous == 1) { + post.uid = null; + } + return post; + } + return null; }; Posts.getPostsData = async function (pids) {