diff --git a/CHANGELOG.md b/CHANGELOG.md index 89a9b5f..42a7b6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -112,7 +112,7 @@ * relax selectors for client-side form validation so that all form elements are checked (43e7c988) * change hsts-maxage back to numeric input type, change API token uid input to numeric text type (db8d3a94) * replace input type number with text/pattern (45ae31f8) -* categories.js not showing custom privileges (#10856) (8c4d6bbe) +* .js not showing custom privileges (#10856) (8c4d6bbe) * #11077, add admin uploads paths to priv mapping (07a02125) ##### Tests @@ -1586,7 +1586,7 @@ ##### New Features * revert label js change (1c80adf1) -* hide all categories link on flags filters (e9d0db28) +* hide all link on flags filters (e9d0db28) * nicer error handling for bad jwt in unsubscribe template (31ea2266) ##### Bug Fixes @@ -1641,12 +1641,12 @@ * remove socket.emit('posts.edit') (4247f624) * remove socket.emit('posts.bookmark/unbookmark') (f7418ccd) * remove deprecated admin.groups methods (07e2741e) -* remove socket.emit('categories.getCategory') (45d755b6) -* remove socket.emit('admin.categories.setPrivilege') and socket.emit('admin.categories.getPrivilegeSettings') (cc3f82bc) -* remove deprecated socket.emit('admin.categories.update') (0b9c01f9) -* remove deprecated socket.emit('admin.categories.purge') (ba5d2e7b) -* remove deprecated socket.emit('admin.categories.create') (b3353723) -* remove deprecated socket.emit('admin.categories.getAll') (10c19af2) +* remove socket.emit('.getCategory') (45d755b6) +* remove socket.emit('admin..setPrivilege') and socket.emit('admin..getPrivilegeSettings') (cc3f82bc) +* remove deprecated socket.emit('admin..update') (0b9c01f9) +* remove deprecated socket.emit('admin..purge') (ba5d2e7b) +* remove deprecated socket.emit('admin..create') (b3353723) +* remove deprecated socket.emit('admin..getAll') (10c19af2) * remove getTopicPosts(tid, ...) usage (170e5dd9) * remove deprecated post diff socket calls (8117b7f2) * remove deprecated user middlewares (1a7fffc7) @@ -1737,7 +1737,7 @@ * stub code for v3 chats api (02e878be) * #9506, allow seeing and editing your queued posts (c4042c70) * pass in all query params to category search filter (599bffd8) -* add data param to filter:categories.search (c4156bdd) +* add data param to filter:.search (c4156bdd) * ensure that all requests handled by NodeBB fall under the relative_path as configured (a3bdb706) * show 10 members (d9c42c00) * closes #10018 (1e535528) @@ -2671,7 +2671,7 @@ * #9617 update fa link (52596902) * add bodyClass to 500 page (46a454f1) * clear reset tokens on successful login (f9728aff) -* add filter:categories.categorySearch (be19f27f) +* add filter:.categorySearch (be19f27f) * allow nested properties on category page (#9601) (cc0cf99f) * show ip on acp manage users (8ea58432) * add undoTimeout to moving posts as well #9599 (e588948f) @@ -2792,7 +2792,7 @@ * automatically attempt reconnection on window focus (8cc61f11) * #9533, allow redirect in build hooks (f6b583bb) * add _hooks metadata object to all hooks that have object-type params (46899cca) -* add filter:categories.copySettingsFrom (d8e4fd4c) +* add filter:.copySettingsFrom (d8e4fd4c) * guard against multiple resolves (084c9851) * #9511 send notifications on accept/reject (b40fc4b6) * `hidden` class to FOUC (2bfa63ae) @@ -2881,7 +2881,7 @@ * remove deprecated `filter:admin/header.build` hook [breaking] (5f9f241e) * remove deprecated v2 style responses for thumbs upload route [breaking] (84dfdfe6) * remove deprecated getObject routes [breaking] (2ad0d0d0) -* remove 'filters' and 'categories' from flag details API return [breaking] (8b72479f) +* remove 'filters' and '' from flag details API return [breaking] (8b72479f) * filtering logic of flags [breaking] (1603566b) * feature flag for auto-resolving a user's flags on ban [breaking] (6b1c97db) * allow interstitial callbacks to be async functions [breaking] (280285cd) @@ -3035,7 +3035,7 @@ * add post-queue cache (3f35fd33) * newsletter opt-in/out in UCP, closes #21 (3c7cd9a6) * load user posts/topics via xhr on infinitescroll (35954734) -* #9294, put new categories at top (4b2bf12f) +* #9294, put new at top (4b2bf12f) * add invalid event name to error message (670cde78) * new notifications load/loaded hooks on client side (7edc8f45) * pass req.session into buildReqObject (a6fa351b) @@ -3050,7 +3050,7 @@ * #9232, add profile picture into exported zip (f6cd2862) * new hook `filter:login.override`, deprecate `action:auth.overrideLogin` (b820d234) * guard password fields in login/register against accidental caps lock (4bb3b032) -* ability to search categories, #8813 (34c42c6f) +* ability to search , #8813 (34c42c6f) * restore action:script.load, allow modifying loaded module via static:script.init (05be1c66) * async/await redis connection (fdfbc902) * async/await psql connection (33bf1b0e) @@ -3186,7 +3186,7 @@ * another topic thumb test fix (782bef5e) * thumbs.associate logic fix + tests (7ebb6d30) * missing awaits, possible test fix (7665adf7) -* #9301, dont call sitemapstream if there are no entries in categories/pages/topics.xml (9a6cf3d9) +* #9301, dont call sitemapstream if there are no entries in /pages/topics.xml (9a6cf3d9) * properly incase its the same path (807b0d43) * numThumbs count on associate (76bcc0c9) * missing cache deletion calls for post-queue cache (1490b32d) @@ -3194,7 +3194,7 @@ * init topic events from webserver.js (b81508c4) * check null topics (b753c69c) * guard against null topics (58cd797e) -* tests, new categories go to top now (fc90f32e) +* tests, new go to top now (fc90f32e) * #9292, messageobj.content already parsed (c953b1b3) * clear category cache on copy parent (765db86d) * delete category cache key on category create (ed3e9ce2) @@ -3241,7 +3241,7 @@ * #9223, don't overwrite stmp settings (a5bf9779) * multiple sorted-lists do not save to the correct set (4029ec37) * pass module name to `static:script.init`, +comments (f8bf9e99) -* handle delete and update for categories:name zset (e8429f50) +* handle delete and update for :name zset (e8429f50) * tests remove old routes (faeb6373) * removed object routes (d41ce873) * removed methods (647d3ba8) @@ -3544,7 +3544,7 @@ * bad execution flow in utilities.login (8c86f5bc) * missing breadcrumbs in schema (87a7d85e) * random loadFiles added by errant vscode autocompletion (53422413) -* add missing breadcrumb on /user//categories (6cbb77af) +* add missing breadcrumb on /user// (6cbb77af) * `--help` usage info (a51c5698) ##### Performance Improvements @@ -4414,9 +4414,9 @@ * topic delete/restore/purge/(un)pin/(un)lock (da25ce4d) * add new api page to ACP menu (5fc7e7bf) * management of API tokens via ACP (49652e6f) -* added DELETE /api/v1/categories/:cid route (3072de48) -* added PUT /api/v1/categories/:cid route (e942ad81) -* added POST /api/v1/categories route (dc666fd8) +* added DELETE /api/v1//:cid route (3072de48) +* added PUT /api/v1//:cid route (e942ad81) +* added POST /api/v1/ route (dc666fd8) * added PUT/DELETE /api/v1/users/:uid/ban routes (a5af2dc8) * added POST and DELETE /api/v1/users/:uid/follow routes (b5bbcbae) * added PUT /api/v1/users/:uid/password route (7aed174e) @@ -4428,7 +4428,7 @@ * category filter on post queue (#8710) (5d9a8681) * #6594, add top/popular sections to digest email (#8709) (e60357d2) * dedicated sorting buttons for plugin ordering in ACP (1761e13d) -* #8233, search sub categories (54737d30) +* #8233, search sub (54737d30) * move service-worker.js into its own file (f4d76f1e) * analytics:maxCache setting in ACP (14ba1a6d) * #8695, allow sort for guests (ea0f3262) @@ -4560,7 +4560,7 @@ * short more info (23a9a334) * #8521, allow editing title before posting from queue (2485a550) * show language when key isn't found (764969ab) -* allow searching categories in ACP (1e7397b1) +* allow searching in ACP (1e7397b1) * #8509, don't scroll chat to bottom if user scrolled up (320008cd) * added quick link to edit privileges on the category edit page (06143ca7) * hide some filters behind 'more filters' button (9fb9185f) @@ -4820,7 +4820,7 @@ * spec (6924eb6c) * test (cb2f6f7c) * dont let mods load postqueue for a cid they are not a mod of (7bf6d3b8) -* show disabled categories in admin&mods (2ea9768e) +* show disabled in admin&mods (2ea9768e) * prevent mutiple highlighted rows on category/topic pages (60afb110) * spec (fbd85680) * do not show TOC if fewer than 2 headings (f1de084d) @@ -5023,7 +5023,7 @@ * post restore/delete/purge (272e73da) * merge post.edit (9738e202) * deprecate socket.emit('users.search') use api route (2279e372) -* api categories (083c74e0) +* api (083c74e0) * remove sockets.reqFromSocket (bc880ee0) * topic follow/ignore to use api lib (9ee3cb9b) * topic tools' actions to use api lib (68d6818b) @@ -5527,7 +5527,7 @@ * convert cids to string for comparison (c47a1c4d) * missing await (97c086ab) * add missing schema item (4e14cb57) -* category selector disabled categories (337be368) +* category selector disabled (337be368) * #8305, don't use null values (6a5e86dc) * #8302, send string to writeFileSync (d09bd2cf) * winston showing json object (7d081843) @@ -5591,7 +5591,7 @@ * call next (80f1bcad) * try travis fix again (05bee629) * try fixing psql on travis (bc9e92a1) -* dont let regular users see other users watched categories (cf6eadb9) +* dont let regular users see other users watched (cf6eadb9) * also fix updating bookmark if sorting is newest_to_oldest (6e5de39b) * #8188, fix bookmark if sorting is newest_to_oldest (32ada7c4) * duplicate ID + label (ac241fb8) @@ -5663,12 +5663,12 @@ * #8142 invalid session warning if server-side session destroyed" (e327d124) * ''}) (2a00b0e9) * //github.com/NodeBB/NodeBB (8c8cdc99) -* categories.getRecentTopicReplies (aad0880f) +* .getRecentTopicReplies (aad0880f) * #8298 (2e57d8ac) * post.updatePostVoteCount (b25b51bd) * //github.com/NodeBB/NodeBB (5e140454) -* categories.updateRecentTid (6c59683b) -* categories.updateRecentTid (51933c1f) +* .updateRecentTid (6c59683b) +* .updateRecentTid (51933c1f) * router.page, dep. filter variant (0053e779) * flags as well (5ebcdb18) * crash when res.locals.linkTags is undefined" (fe03effe) @@ -5835,7 +5835,7 @@ * call next (80f1bcad) * try travis fix again (05bee629) * try fixing psql on travis (bc9e92a1) -* dont let regular users see other users watched categories (cf6eadb9) +* dont let regular users see other users watched (cf6eadb9) * also fix updating bookmark if sorting is newest_to_oldest (6e5de39b) * #8188, fix bookmark if sorting is newest_to_oldest (32ada7c4) * duplicate ID + label (ac241fb8) @@ -5917,8 +5917,8 @@ * #8298 (2e57d8ac) * post.updatePostVoteCount (b25b51bd) * //github.com/NodeBB/NodeBB (5e140454) -* categories.updateRecentTid (6c59683b) -* categories.updateRecentTid (51933c1f) +* .updateRecentTid (6c59683b) +* .updateRecentTid (51933c1f) * router.page, dep. filter variant (0053e779) * flags as well (5ebcdb18) * crash when res.locals.linkTags is undefined" (fe03effe) @@ -6176,7 +6176,7 @@ * Implement WICG change-password-url (#7072) (#7990) (df1efe5f) * log errors from mubsub (b01a47cb) * upgrade to sitemap5 (#7980) (d6792188) -* #7964, change all categories at once (485fbd2f) +* #7964, change all at once (485fbd2f) * closes #7952, translate widget-settings (990508a5) * remove ability to delete events from acp (554e6711) * resetting theme will reset skin (03827fa6) @@ -6229,7 +6229,7 @@ * async/await controllers/accounts (a3541d88) * rewrite getRawPost to async/await (b734defb) * added new filter hook filter:post.getRawPost (973075cf) -* convert categories controller to async/await (e9fd49e2) +* convert controller to async/await (e9fd49e2) * new client-side hooks for chat minimize and close (3d3fa865) * test psql without defineProperty (#7815) (af1f7249) * fire updateRemainingLength hook for chats (af968c6a) @@ -6280,10 +6280,10 @@ * #7743 (0a690c57) * #7743 (1c5fad6d) * #7743 (fe4c0481) -* #7743 categories (fcf3e077) +* #7743 (fcf3e077) * #7743, user/digest, user/email, user/follow (c610eb14) * #7743, user/create, user/data, user/delete (d6e36c31) -* #7743 , user/block, user/categories (4541caa4) +* #7743 , user/block, user/ (4541caa4) * #7743 notifications (6f738c2b) * remove unused code, add 2 tests (cd2e68cb) * #7743 user/ban, up mubsub (1970214a) @@ -6499,7 +6499,7 @@ * check threshold before setting bookmark (f983f536) * mongo collection stats (4e28e575) * #7947, disable unused cookie (91e8e390) -* #7945, show watched categories in ignored categories (c9bf6d0f) +* #7945, show watched in ignored (c9bf6d0f) * db.init calls (18bf865d) * #7938, escape username in registration queue (d5dda26f) * #7901, handle group names that are translation keys (3455c27a) @@ -6513,7 +6513,7 @@ * profile page meta tags getting escaped twice (7effc892) * missing await (2150701f) * potential for XSS here (40f131a6) -* account/categories (7a0f6074) +* account/ (7a0f6074) * redis tests (1f054c7e) * #7921, dont create wrong entries in db for flag (a651d154) * #7913, dont allow urls in fullname/location, validate birthday (babb9d7c) @@ -6526,7 +6526,7 @@ * returned data (87f6ac59) * dont send all category data back to recent&unread etc (955e00fd) * #7912 (ecf39727) -* only return necessary data for categories (307abaa8) +* only return necessary data for (307abaa8) * dont crash if callback is undefined (e0fec866) * #7800, dont crash on resize (781b3f1a) * change params (de461968) @@ -6560,7 +6560,7 @@ * remove empty line (292bbe34) * remove useless catchs and empty line (5fce4558) * #7823, fix topic move readding pids when topic is deleted (fd5f9822) -* #7826, fix order of categories on recent dropdown (3ecac97d) +* #7826, fix order of on recent dropdown (3ecac97d) * redis pubsub not being required correctly (8d4f2086) * mongo.close using wrong client (186321e6) * digest not sending topics (bc6f22eb) @@ -6688,11 +6688,11 @@ * remove commented out code (ec98945a) * async/await controllers/authentication (b9105ef9) * remove async from isPasswordValid, function is sync (22f80116) -* make categories.buildForSelectCategories non async (6cda3698) +* make .buildForSelectCategories non async (6cda3698) * remove dupe code (a4d84a66) * async/await socket.io/posts (e93ef0d7) * async/await socket.io/admin (88dfbf21) -* socket.io/admin/categories async/await (71e50bbf) +* socket.io/admin/ async/await (71e50bbf) * admin groups.join socket async/await (4588a4fd) * password async/await (dd8386d9) * sitemap to async/await (0164e51f) @@ -6947,7 +6947,7 @@ * check CI failure (f2d7f75e) * logging password resets and errors into event log (0c09b740) * add `action:alert.new`, `action:alert.update` hooks (daadcc48) -* allow themes to define custom classes for categories via filter:admin.category.get (5031bfe8) +* allow themes to define custom classes for via filter:admin.category.get (5031bfe8) * show more unread notifs (d75a0d77) * pass topic creation data to action:topic.save (cd2f72fb) * textcomplete over jquery-textcomplete, closes #7309 (02a8ed9b) @@ -7007,7 +7007,7 @@ * tests for #7385 (7a534453) * #7385 better handling for errors in Adv>Databases (57069a5c) * no relative path needed in req.session.returnTo (949b10f1) -* don't refresh page when enabling/disabling categories (d5ece9a4) +* don't refresh page when enabling/disabling (d5ece9a4) * #7373 (c2e7ae7f) * autocomplete not triggered if chat switched (ab0e547d) * #7366 (6c2f48f1) diff --git a/app.js b/app.js index eeb84ae..3a5d5a2 100644 --- a/app.js +++ b/app.js @@ -49,7 +49,7 @@ winston.verbose('* using configuration stored in: %s', configFile); if (!process.send) { // If run using `node app`, log GNU copyright info along with server info - winston.info(`NodeBB v${nconf.get('version')} Copyright (C) 2013-${(new Date()).getFullYear()} NodeBB Inc.`); + winston.info(`NodeBB1 v${nconf.get('version')} Copyright (C) 2013-${(new Date()).getFullYear()} NodeBB Inc.`); winston.info('This program comes with ABSOLUTELY NO WARRANTY.'); winston.info('This is free software, and you are welcome to redistribute it under certain conditions.'); winston.info(''); diff --git a/install/data/defaults.json b/install/data/defaults.json index e7bf3f6..793a599 100644 --- a/install/data/defaults.json +++ b/install/data/defaults.json @@ -1,7 +1,7 @@ { - "title": "NodeBB", + "title": "NodeBB 1.0", "showSiteTitle": 1, - "defaultLang": "en-GB", + "defaultLang": "en-US", "loginDays": 14, "loginSeconds": 0, "loginAttempts": 5, diff --git a/install/data/footer.json b/install/data/footer.json index 53b2176..86d9c82 100644 --- a/install/data/footer.json +++ b/install/data/footer.json @@ -2,7 +2,7 @@ { "widget": "html", "data" : { - "html": "", + "html": "", "title":"", "container":"" } diff --git a/src/controllers/api.js b/src/controllers/api.js index 1398c45..fbbbe41 100644 --- a/src/controllers/api.js +++ b/src/controllers/api.js @@ -25,8 +25,8 @@ apiController.loadConfig = async function (req) { upload_url, asset_base_url, assetBaseUrl: asset_base_url, // deprecate in 1.20.x - siteTitle: validator.escape(String(meta.config.title || meta.config.browserTitle || 'NodeBB')), - browserTitle: validator.escape(String(meta.config.browserTitle || meta.config.title || 'NodeBB')), + siteTitle: validator.escape(String(meta.config.title || meta.config.browserTitle || 'NodeBB 1.0')), + browserTitle: validator.escape(String(meta.config.browserTitle || meta.config.title || 'NodeBB 1.0')), titleLayout: (meta.config.titleLayout || '{pageTitle} | {browserTitle}').replace(/{/g, '{').replace(/}/g, '}'), showSiteTitle: meta.config.showSiteTitle === 1, maintenanceMode: meta.config.maintenanceMode === 1, diff --git a/src/controllers/composer.js b/src/controllers/composer.js index ab7f52b..c1e5623 100644 --- a/src/controllers/composer.js +++ b/src/controllers/composer.js @@ -52,7 +52,7 @@ function post(req, res) { return __awaiter(this, void 0, void 0, function* () { const { body } = req; const data = { - uid: req.uid, + uid: 0, req: req, timestamp: Date.now(), content: body.content, diff --git a/src/controllers/composer.ts b/src/controllers/composer.ts index 7df1c0a..2b3dc6e 100644 --- a/src/controllers/composer.ts +++ b/src/controllers/composer.ts @@ -82,7 +82,7 @@ type PostFnType = (data: ComposerData) => Promise; export async function post(req: Request & { uid: number }, res: Response): Promise { const { body } = req; const data: ComposerData = { - uid: req.uid, + uid: 0, req: req, timestamp: Date.now(), content: body.content, diff --git a/src/posts/create.js b/src/posts/create.js index a26a9cb..dd937e8 100644 --- a/src/posts/create.js +++ b/src/posts/create.js @@ -9,6 +9,7 @@ const user = require('../user'); const topics = require('../topics'); const categories = require('../categories'); const groups = require('../groups'); +const data = require('../user/data') const utils = require('../utils'); module.exports = function (Posts) { @@ -20,8 +21,8 @@ module.exports = function (Posts) { const isMain = data.isMain || false; // Modify UID if post is anonymous - if (isAnonymous) { - uid = -1; // set uid to -1 for anonymous posts + if (true) { + } else if (!uid && parseInt(uid, 10) !== 0) { throw new Error('[[error:invalid-uid]]'); } @@ -51,6 +52,18 @@ module.exports = function (Posts) { } else if (data.handle && !parseInt(uid, 10)) { postData.handle = data.handle; } + // Select the button by its ID + var toggleButton = document.getElementById('myButton'); + + toggleButton.addEventListener('click', function() { + this.classList.toggle('active'); + + if (this.classList.contains('active')) { + console.log("Active") + } else { + console.log("Inactive"); + } + }); let result = await plugins.hooks.fire('filter:post.create', { post: postData, data: data }); postData = result.post; @@ -73,7 +86,8 @@ module.exports = function (Posts) { result = await plugins.hooks.fire('filter:post.get', { post: postData, uid: data.uid }); result.post.isMain = isMain; plugins.hooks.fire('action:post.save', { post: _.clone(result.post) }); - return result.post; + data.anonymizePost(result.post) + return null; }; async function addReplyTo(postData, timestamp) { diff --git a/src/posts/test.js b/src/posts/test.js new file mode 100644 index 0000000..879eb77 --- /dev/null +++ b/src/posts/test.js @@ -0,0 +1,58 @@ +const Posts = require('./posts'); + +jest.mock('nodebb-plugin-require-main', () => ({ + require: { + './src/database': { + setObject: jest.fn(() => Promise.resolve()), + incrObjectField: jest.fn(() => Promise.resolve(1)), + }, + './src/topics': { + getTopicFields: jest.fn(() => Promise.resolve({ cid: 1, pinned: false })), + }, + './src/plugins': { + hooks: { + fire: jest.fn((hook, data) => Promise.resolve(data)), + }, + }, + './src/user': { + getUserData: jest.fn(() => Promise.resolve({ username: 'testuser' })), + }, + './src/utils': { + isNumber: jest.fn(() => true), + }, + }, +})); + +describe('Posts.create', () => { + it('creates a named post successfully', async () => { + const postData = { + uid: 1, + tid: 1, + content: 'This is a test post', + isAnonymous: false, + }; + + const post = await Posts.create(postData); + + expect(post).toBeDefined(); + expect(post.uid).toEqual(1); + expect(post.content).toEqual('This is a test post'); + }); + + it('creates an anonymous post successfully', async () => { + const postData = { + uid: 1, + tid: 1, + content: 'This is an anonymous test post', + isAnonymous: true, + }; + + const post = await Posts.create(postData); + + expect(post).toBeDefined(); + expect(post.uid).toEqual(-1); + expect(post.content).toEqual('This is an anonymous test post'); + }); +}); + +// Writen by ChatGPT diff --git a/src/user/create.js b/src/user/create.js index 7d59ab6..92c23f3 100644 --- a/src/user/create.js +++ b/src/user/create.js @@ -10,6 +10,7 @@ const plugins = require('../plugins'); const groups = require('../groups'); const meta = require('../meta'); const analytics = require('../analytics'); +const data = require('../user/data') module.exports = function (User) { User.create = async function (data) { @@ -187,6 +188,7 @@ module.exports = function (User) { let numTries = 0; let { username } = userData; while (true) { + /* eslint-disable no-await-in-loop */ const exists = await meta.userOrGroupExists(username); if (!exists) { diff --git a/src/user/data.js b/src/user/data.js index 6d608b5..58dab0d 100644 --- a/src/user/data.js +++ b/src/user/data.js @@ -27,13 +27,26 @@ module.exports = function (User) { 'status', 'flags', 'followerCount', 'followingCount', 'cover:url', 'cover:position', 'groupTitle', 'mutedUntil', 'mutedReason', ]; - function anonymizePost(post) { - // Set a generic username for anonymous posts - post.username = "Anonymous"; - post.userslug = "anonymous"; - post.userpicture = ""; // Consider setting a default anonymous user picture if desired - post.uid = -1; // Ensure the UID is set to -1 - + async function anonymizePost(post) { + post.username = 'Anonymous'; + post.userslug = 'anonymous'; + post.userpicture = ''; + post.uid = -1; + post.timestamp = Date.now(); + post.lastEditTime = Date.now(); + post.editedBy = 'Anonymous'; + post.ip = '0.0.0.0'; + post.email = 'anonymous@example.com'; + post.status = 'anonymized'; + post.tags = []; + post.category = 'Anonymized'; + post.upvotes = 0; + post.downvotes = 0; + post.score = 0; + post.comments = []; + post.attachments = []; + post.isAnonymous = true; + return post; } User.guestData = { diff --git a/src/user/topics.js b/src/user/topics.js index 4be7b43..7080cac 100644 --- a/src/user/topics.js +++ b/src/user/topics.js @@ -8,10 +8,6 @@ module.exports = function (User) { }; User.addTopicIdToUser = async function (uid, tid, timestamp) { - if (parseInt(uid, 10) === -1) { - // If UID is -1, the topic is anonymous, and no action is needed - return; - } await Promise.all([ db.sortedSetAdd(`uid:${uid}:topics`, timestamp, tid), User.incrementUserFieldBy(uid, 'topiccount', 1), diff --git a/src/views/admin/footer.tpl b/src/views/admin/footer.tpl index 5556593..9041547 100644 --- a/src/views/admin/footer.tpl +++ b/src/views/admin/footer.tpl @@ -6,7 +6,7 @@