From 89e059a0841f4265d16b28a99ebf847dd10fa055 Mon Sep 17 00:00:00 2001 From: Peter Jaszkowiak Date: Tue, 24 Jan 2023 17:59:06 -0700 Subject: [PATCH 01/17] fix: import resolution within plugin modules (#11200) --- src/meta/js.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/meta/js.js b/src/meta/js.js index 454b682cc3..e7aab11509 100644 --- a/src/meta/js.js +++ b/src/meta/js.js @@ -40,14 +40,24 @@ async function linkModules() { await Promise.all(Object.keys(modules).map(async (relPath) => { const srcPath = path.join(__dirname, '../../', modules[relPath]); const destPath = path.join(__dirname, '../../build/public/src/modules', relPath); + const destDir = path.dirname(destPath); + const [stats] = await Promise.all([ fs.promises.stat(srcPath), - mkdirp(path.dirname(destPath)), + mkdirp(destDir), ]); + if (stats.isDirectory()) { await file.linkDirs(srcPath, destPath, true); } else { - await fs.promises.copyFile(srcPath, destPath); + // Get the relative path to the destination directory + const relPath = path.relative(destDir, srcPath) + // and convert to a posix path + .split(path.sep).join(path.posix.sep); + + // Instead of copying file, create a new file re-exporting it + // This way, imports in modules are resolved correctly + await fs.promises.writeFile(destPath, `export * from '${relPath}'`); } })); } From 4c46ff42f652329294436009403777d17b701038 Mon Sep 17 00:00:00 2001 From: Misty Release Bot Date: Wed, 25 Jan 2023 19:37:33 +0000 Subject: [PATCH 02/17] chore: incrementing version number - v2.8.3 --- install/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/package.json b/install/package.json index c2c63ced4b..0db03bf17f 100644 --- a/install/package.json +++ b/install/package.json @@ -2,7 +2,7 @@ "name": "nodebb", "license": "GPL-3.0", "description": "NodeBB Forum", - "version": "2.8.2", + "version": "2.8.3", "homepage": "http://www.nodebb.org", "repository": { "type": "git", From eb2841eed31fbc52e116c16478399e0e075c5104 Mon Sep 17 00:00:00 2001 From: Misty Release Bot Date: Wed, 25 Jan 2023 19:37:34 +0000 Subject: [PATCH 03/17] chore: update changelog for v2.8.3 --- CHANGELOG.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index db0d025621..cd5e9597e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,54 @@ +#### v2.8.3 (2023-01-25) + +##### Chores + +* remove extraneous lines from changelog (48c9f447) +* incrementing version number - v2.8.2 (050e43f8) +* update changelog for v2.8.2 (66aa3169) +* incrementing version number - v2.8.1 (727f879e) +* incrementing version number - v2.8.0 (8e77673d) +* incrementing version number - v2.7.0 (96cc0617) +* incrementing version number - v2.6.1 (7e52a7a5) +* incrementing version number - v2.6.0 (e7fcf482) +* incrementing version number - v2.5.8 (dec0e7de) +* incrementing version number - v2.5.7 (5836bf4a) +* incrementing version number - v2.5.6 (c7bd7dbf) +* incrementing version number - v2.5.5 (3509ed94) +* incrementing version number - v2.5.4 (e83260ca) +* incrementing version number - v2.5.3 (7e922936) +* incrementing version number - v2.5.2 (babcd17e) +* incrementing version number - v2.5.1 (ce3aa950) +* incrementing version number - v2.5.0 (01d276cb) +* incrementing version number - v2.4.5 (dd3e1a28) +* incrementing version number - v2.4.4 (d5525c87) +* incrementing version number - v2.4.3 (9c647c6c) +* incrementing version number - v2.4.2 (3aa7b855) +* incrementing version number - v2.4.1 (60cbd148) +* incrementing version number - v2.4.0 (4834cde3) +* incrementing version number - v2.3.1 (d2425942) +* incrementing version number - v2.3.0 (046ea120) + +##### Bug Fixes + +* import resolution within plugin modules (#11200) (89e059a0) +* #11195, allow users with admin:users privilege to delete users in acp (0bffd3d9) +* #11194, allow access to sub dashboard pages (7d04e952) +* #11136, tests, and returning the proper number of arrays (459bc523) +* #11136, only show mods of active categories when getModeratorUids is called (39e009c0) +* closes #11173, clear require cache if wrong dependency is installed (747cb1f0) +* **deps:** + * downgrade swagger-parser to v9 (00e48803) + * pinning sub dependency json-schema-ref-parser to 9.0.9 (9c250b78) + +##### Reverts + +* a788bd1344825ad4759e39d6e98d8bf3695bd639 (fecd84d1) +* 9c250b78b05ca2abf31a79971ed0c60ca07664ec, fix: comment out broken test for now (a788bd13) + +##### Tests + +* fix broken test (f295174e) + #### v2.8.2 (2023-01-13) ##### Chores From c3653bee60740e410bf28808e29ffed6ab373bf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 26 Jan 2023 09:27:16 -0500 Subject: [PATCH 04/17] Revert "fix: import resolution within plugin modules (#11200)" This reverts commit 89e059a0841f4265d16b28a99ebf847dd10fa055. --- src/meta/js.js | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/meta/js.js b/src/meta/js.js index e7aab11509..454b682cc3 100644 --- a/src/meta/js.js +++ b/src/meta/js.js @@ -40,24 +40,14 @@ async function linkModules() { await Promise.all(Object.keys(modules).map(async (relPath) => { const srcPath = path.join(__dirname, '../../', modules[relPath]); const destPath = path.join(__dirname, '../../build/public/src/modules', relPath); - const destDir = path.dirname(destPath); - const [stats] = await Promise.all([ fs.promises.stat(srcPath), - mkdirp(destDir), + mkdirp(path.dirname(destPath)), ]); - if (stats.isDirectory()) { await file.linkDirs(srcPath, destPath, true); } else { - // Get the relative path to the destination directory - const relPath = path.relative(destDir, srcPath) - // and convert to a posix path - .split(path.sep).join(path.posix.sep); - - // Instead of copying file, create a new file re-exporting it - // This way, imports in modules are resolved correctly - await fs.promises.writeFile(destPath, `export * from '${relPath}'`); + await fs.promises.copyFile(srcPath, destPath); } })); } From b9553613ab0de13961bbf31eb2d1a8c7554a3999 Mon Sep 17 00:00:00 2001 From: Misty Release Bot Date: Thu, 26 Jan 2023 14:38:06 +0000 Subject: [PATCH 05/17] chore: incrementing version number - v2.8.4 --- install/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/package.json b/install/package.json index 0db03bf17f..63c02e8401 100644 --- a/install/package.json +++ b/install/package.json @@ -2,7 +2,7 @@ "name": "nodebb", "license": "GPL-3.0", "description": "NodeBB Forum", - "version": "2.8.3", + "version": "2.8.4", "homepage": "http://www.nodebb.org", "repository": { "type": "git", From c13f0e212821100b2afeb4d5b6d241f986b8a0c1 Mon Sep 17 00:00:00 2001 From: Misty Release Bot Date: Thu, 26 Jan 2023 14:38:07 +0000 Subject: [PATCH 06/17] chore: update changelog for v2.8.4 --- CHANGELOG.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd5e9597e1..a8b58c9fce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,33 @@ +#### v2.8.4 (2023-01-26) + +##### Chores + +* incrementing version number - v2.8.3 (c20b20a7) +* update changelog for v2.8.3 (eb2841ee) +* incrementing version number - v2.8.2 (050e43f8) +* incrementing version number - v2.8.1 (727f879e) +* incrementing version number - v2.8.0 (8e77673d) +* incrementing version number - v2.7.0 (96cc0617) +* incrementing version number - v2.6.1 (7e52a7a5) +* incrementing version number - v2.6.0 (e7fcf482) +* incrementing version number - v2.5.8 (dec0e7de) +* incrementing version number - v2.5.7 (5836bf4a) +* incrementing version number - v2.5.6 (c7bd7dbf) +* incrementing version number - v2.5.5 (3509ed94) +* incrementing version number - v2.5.4 (e83260ca) +* incrementing version number - v2.5.3 (7e922936) +* incrementing version number - v2.5.2 (babcd17e) +* incrementing version number - v2.5.1 (ce3aa950) +* incrementing version number - v2.5.0 (01d276cb) +* incrementing version number - v2.4.5 (dd3e1a28) +* incrementing version number - v2.4.4 (d5525c87) +* incrementing version number - v2.4.3 (9c647c6c) +* incrementing version number - v2.4.2 (3aa7b855) +* incrementing version number - v2.4.1 (60cbd148) +* incrementing version number - v2.4.0 (4834cde3) +* incrementing version number - v2.3.1 (d2425942) +* incrementing version number - v2.3.0 (046ea120) + #### v2.8.3 (2023-01-25) ##### Chores From f6c96948fe7cee13575ab9c93af6fe7fb9d7b722 Mon Sep 17 00:00:00 2001 From: Peter Jaszkowiak Date: Fri, 27 Jan 2023 07:17:38 -0700 Subject: [PATCH 07/17] fix: import resolution within plugin modules (#11219) use module.exports = require('..') export * from '..' didn't work in some cases --- src/meta/js.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/meta/js.js b/src/meta/js.js index 454b682cc3..e1998443d8 100644 --- a/src/meta/js.js +++ b/src/meta/js.js @@ -40,14 +40,24 @@ async function linkModules() { await Promise.all(Object.keys(modules).map(async (relPath) => { const srcPath = path.join(__dirname, '../../', modules[relPath]); const destPath = path.join(__dirname, '../../build/public/src/modules', relPath); + const destDir = path.dirname(destPath); + const [stats] = await Promise.all([ fs.promises.stat(srcPath), - mkdirp(path.dirname(destPath)), + mkdirp(destDir), ]); + if (stats.isDirectory()) { await file.linkDirs(srcPath, destPath, true); } else { - await fs.promises.copyFile(srcPath, destPath); + // Get the relative path to the destination directory + const relPath = path.relative(destDir, srcPath) + // and convert to a posix path + .split(path.sep).join(path.posix.sep); + + // Instead of copying file, create a new file re-exporting it + // This way, imports in modules are resolved correctly + await fs.promises.writeFile(destPath, `module.exports = require('${relPath}');`); } })); } From 93ccf604db3b482becc51feed877c98e5c538b04 Mon Sep 17 00:00:00 2001 From: Misty Release Bot Date: Fri, 27 Jan 2023 14:35:24 +0000 Subject: [PATCH 08/17] chore: incrementing version number - v2.8.5 --- install/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/package.json b/install/package.json index 63c02e8401..34c5e0bf05 100644 --- a/install/package.json +++ b/install/package.json @@ -2,7 +2,7 @@ "name": "nodebb", "license": "GPL-3.0", "description": "NodeBB Forum", - "version": "2.8.4", + "version": "2.8.5", "homepage": "http://www.nodebb.org", "repository": { "type": "git", From 24e58c289587c52aaf02417a276ac120dfac7606 Mon Sep 17 00:00:00 2001 From: Misty Release Bot Date: Fri, 27 Jan 2023 14:35:25 +0000 Subject: [PATCH 09/17] chore: update changelog for v2.8.5 --- CHANGELOG.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a8b58c9fce..8b793bc928 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,38 @@ +#### v2.8.5 (2023-01-27) + +##### Chores + +* incrementing version number - v2.8.4 (a46b2bbc) +* update changelog for v2.8.4 (c13f0e21) +* incrementing version number - v2.8.3 (c20b20a7) +* incrementing version number - v2.8.2 (050e43f8) +* incrementing version number - v2.8.1 (727f879e) +* incrementing version number - v2.8.0 (8e77673d) +* incrementing version number - v2.7.0 (96cc0617) +* incrementing version number - v2.6.1 (7e52a7a5) +* incrementing version number - v2.6.0 (e7fcf482) +* incrementing version number - v2.5.8 (dec0e7de) +* incrementing version number - v2.5.7 (5836bf4a) +* incrementing version number - v2.5.6 (c7bd7dbf) +* incrementing version number - v2.5.5 (3509ed94) +* incrementing version number - v2.5.4 (e83260ca) +* incrementing version number - v2.5.3 (7e922936) +* incrementing version number - v2.5.2 (babcd17e) +* incrementing version number - v2.5.1 (ce3aa950) +* incrementing version number - v2.5.0 (01d276cb) +* incrementing version number - v2.4.5 (dd3e1a28) +* incrementing version number - v2.4.4 (d5525c87) +* incrementing version number - v2.4.3 (9c647c6c) +* incrementing version number - v2.4.2 (3aa7b855) +* incrementing version number - v2.4.1 (60cbd148) +* incrementing version number - v2.4.0 (4834cde3) +* incrementing version number - v2.3.1 (d2425942) +* incrementing version number - v2.3.0 (046ea120) + +##### Bug Fixes + +* import resolution within plugin modules (#11219) (f6c96948) + #### v2.8.4 (2023-01-26) ##### Chores From 6d819b056ef5e853fdaef5072cde0ad15fbb5240 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Mon, 30 Jan 2023 10:43:02 -0500 Subject: [PATCH 10/17] fix: notif filter selecte field --- src/controllers/accounts/notifications.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/controllers/accounts/notifications.js b/src/controllers/accounts/notifications.js index 75c501b1ce..a235f68e4c 100644 --- a/src/controllers/accounts/notifications.js +++ b/src/controllers/accounts/notifications.js @@ -45,10 +45,11 @@ notificationsController.get = async function (req, res, next) { { separator: true }, ]).concat(filters.moderatorFilters); } - const selectedFilter = allFilters.find((filterData) => { + + allFilters.forEach((filterData) => { filterData.selected = filterData.filter === filter; - return filterData.selected; }); + const selectedFilter = allFilters.find(filterData => filterData.selected); if (!selectedFilter) { return next(); } From 1d3c0e5a2bbe6c1b93714e67edef9fa4fac7b02a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Mon, 30 Jan 2023 11:48:10 -0500 Subject: [PATCH 11/17] fix: https://github.com/NodeBB/NodeBB/issues/11239 parseInt uid received from req.body._uid or req.query._uid --- src/middleware/user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/middleware/user.js b/src/middleware/user.js index c3871bd023..11f6c849ed 100644 --- a/src/middleware/user.js +++ b/src/middleware/user.js @@ -37,7 +37,7 @@ module.exports = function (middleware) { const loginAsync = util.promisify(req.login).bind(req); await loginAsync(user, { keepSessionInfo: true }); await controllers.authentication.onSuccessfulLogin(req, user.uid); - req.uid = user.uid; + req.uid = parseInt(user.uid, 10); req.loggedIn = req.uid > 0; return true; } From 0713482bd414219ee4b51804102c7751ff2a4c3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Mon, 30 Jan 2023 12:26:08 -0500 Subject: [PATCH 12/17] feat: #11240, only show relevant users in flags assignee list for user flags-> admins + all users who have `admin:users` privilege for post flags -> admins + global mods + moderators of the category the post is in refactor getModeratorUids function so it can be used for different privileges --- src/categories/index.js | 34 +--------------------------------- src/controllers/mods.js | 28 ++++++++++++++++++++++++++-- src/privileges/admin.js | 5 +++++ src/privileges/categories.js | 4 ++++ src/privileges/global.js | 5 +++++ src/privileges/helpers.js | 35 +++++++++++++++++++++++++++++++++++ 6 files changed, 76 insertions(+), 35 deletions(-) diff --git a/src/categories/index.js b/src/categories/index.js index 619f756642..027913ccd9 100644 --- a/src/categories/index.js +++ b/src/categories/index.js @@ -99,39 +99,7 @@ Categories.getModerators = async function (cid) { }; Categories.getModeratorUids = async function (cids) { - // Only check active categories - const disabled = (await Categories.getCategoriesFields(cids, ['disabled'])).map(obj => obj.disabled); - // cids = cids.filter((_, idx) => !disabled[idx]); - - const groupNames = cids.reduce((memo, cid) => { - memo.push(`cid:${cid}:privileges:moderate`); - memo.push(`cid:${cid}:privileges:groups:moderate`); - return memo; - }, []); - - const memberSets = await groups.getMembersOfGroups(groupNames); - // Every other set is actually a list of user groups, not uids, so convert those to members - const sets = memberSets.reduce((memo, set, idx) => { - if (idx % 2) { - memo.groupNames.push(set); - } else { - memo.uids.push(set); - } - - return memo; - }, { groupNames: [], uids: [] }); - - const uniqGroups = _.uniq(_.flatten(sets.groupNames)); - const groupUids = await groups.getMembersOfGroups(uniqGroups); - const map = _.zipObject(uniqGroups, groupUids); - const moderatorUids = cids.map((cid, index) => { - if (disabled[index]) { - return []; - } - - return _.uniq(sets.uids[index].concat(_.flatten(sets.groupNames[index].map(g => map[g])))); - }); - return moderatorUids; + return await privileges.categories.getUidsWithPrivilege(cids, 'moderate'); }; Categories.getCategories = async function (cids, uid) { diff --git a/src/controllers/mods.js b/src/controllers/mods.js index 48a3bd8ff3..3656146652 100644 --- a/src/controllers/mods.js +++ b/src/controllers/mods.js @@ -1,6 +1,9 @@ 'use strict'; +const _ = require('lodash'); + const user = require('../user'); +const groups = require('../groups'); const posts = require('../posts'); const flags = require('../flags'); const analytics = require('../analytics'); @@ -110,7 +113,6 @@ modsController.flags.detail = async function (req, res, next) { isAdminOrGlobalMod: user.isAdminOrGlobalMod(req.uid), moderatedCids: user.getModeratedCids(req.uid), flagData: flags.get(req.params.flagId), - assignees: user.getAdminsandGlobalModsandModerators(), privileges: Promise.all(['global', 'admin'].map(async type => privileges[type].get(req.uid))), }); results.privileges = { ...results.privileges[0], ...results.privileges[1] }; @@ -119,6 +121,28 @@ modsController.flags.detail = async function (req, res, next) { return next(); // 404 } + async function getAssignees(flagData) { + let uids = []; + const [admins, globalMods] = await Promise.all([ + groups.getMembers('administrators', 0, -1), + groups.getMembers('Global Moderators', 0, -1), + ]); + if (flagData.type === 'user') { + uids = await privileges.admin.getUidsWithPrivilege('admin:users'); + uids = _.uniq(admins.concat(uids)); + } else if (flagData.type === 'post') { + const cid = await posts.getCidByPid(flagData.targetId); + if (!cid) { + return []; + } + uids = (await privileges.categories.getUidsWithPrivilege([cid], 'moderate'))[0]; + uids = _.uniq(admins.concat(globalMods).concat(uids)); + } + const userData = await user.getUsersData(uids); + return userData.filter(u => u && u.userslug); + } + + const assignees = await getAssignees(results.flagData); results.flagData.history = results.isAdminOrGlobalMod ? (await flags.getHistory(req.params.flagId)) : null; if (results.flagData.type === 'user') { @@ -128,7 +152,7 @@ modsController.flags.detail = async function (req, res, next) { } res.render('flags/detail', Object.assign(results.flagData, { - assignees: results.assignees, + assignees: assignees, type_bool: ['post', 'user', 'empty'].reduce((memo, cur) => { if (cur !== 'empty') { memo[cur] = results.flagData.type === cur && ( diff --git a/src/privileges/admin.js b/src/privileges/admin.js index 166236ac76..e77d2e9982 100644 --- a/src/privileges/admin.js +++ b/src/privileges/admin.js @@ -211,3 +211,8 @@ privsAdmin.groupPrivileges = async function (groupName) { const groupPrivilegeList = await privsAdmin.getGroupPrivilegeList(); return await helpers.userOrGroupPrivileges(0, groupName, groupPrivilegeList); }; + +privsAdmin.getUidsWithPrivilege = async function (privilege) { + const uidsByCid = await helpers.getUidsWithPrivilege([0], privilege); + return uidsByCid[0]; +}; diff --git a/src/privileges/categories.js b/src/privileges/categories.js index 8abdd0b34f..76b9248bd2 100644 --- a/src/privileges/categories.js +++ b/src/privileges/categories.js @@ -218,3 +218,7 @@ privsCategories.groupPrivileges = async function (cid, groupName) { const groupPrivilegeList = await privsCategories.getGroupPrivilegeList(); return await helpers.userOrGroupPrivileges(cid, groupName, groupPrivilegeList); }; + +privsCategories.getUidsWithPrivilege = async function (cids, privilege) { + return await helpers.getUidsWithPrivilege(cids, privilege); +}; diff --git a/src/privileges/global.js b/src/privileges/global.js index 472448d4c4..3cfe50e522 100644 --- a/src/privileges/global.js +++ b/src/privileges/global.js @@ -134,3 +134,8 @@ privsGlobal.groupPrivileges = async function (groupName) { const groupPrivilegeList = await privsGlobal.getGroupPrivilegeList(); return await helpers.userOrGroupPrivileges(0, groupName, groupPrivilegeList); }; + +privsGlobal.getUidsWithPrivilege = async function (privilege) { + const uidsByCid = await helpers.getUidsWithPrivilege([0], privilege); + return uidsByCid[0]; +}; diff --git a/src/privileges/helpers.js b/src/privileges/helpers.js index e6a0266f67..b8c45dfdb3 100644 --- a/src/privileges/helpers.js +++ b/src/privileges/helpers.js @@ -6,6 +6,7 @@ const validator = require('validator'); const groups = require('../groups'); const user = require('../user'); +const categories = require('../categories'); const plugins = require('../plugins'); const translator = require('../translator'); @@ -189,4 +190,38 @@ helpers.userOrGroupPrivileges = async function (cid, uidOrGroup, privilegeList) return _.zipObject(privilegeList, isMembers); }; +helpers.getUidsWithPrivilege = async (cids, privilege) => { + const disabled = (await categories.getCategoriesFields(cids, ['disabled'])).map(obj => obj.disabled); + + const groupNames = cids.reduce((memo, cid) => { + memo.push(`cid:${cid}:privileges:${privilege}`); + memo.push(`cid:${cid}:privileges:groups:${privilege}`); + return memo; + }, []); + + const memberSets = await groups.getMembersOfGroups(groupNames); + // Every other set is actually a list of user groups, not uids, so convert those to members + const sets = memberSets.reduce((memo, set, idx) => { + if (idx % 2) { + memo.groupNames.push(set); + } else { + memo.uids.push(set); + } + + return memo; + }, { groupNames: [], uids: [] }); + + const uniqGroups = _.uniq(_.flatten(sets.groupNames)); + const groupUids = await groups.getMembersOfGroups(uniqGroups); + const map = _.zipObject(uniqGroups, groupUids); + const uidsByCid = cids.map((cid, index) => { + if (disabled[index]) { + return []; + } + + return _.uniq(sets.uids[index].concat(_.flatten(sets.groupNames[index].map(g => map[g])))); + }); + return uidsByCid; +}; + require('../promisify')(helpers); From d68352cce522f5f13ebb024cf97b8ca0dcb4669e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Mon, 30 Jan 2023 12:35:08 -0500 Subject: [PATCH 13/17] lint: remove unused --- src/categories/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/categories/index.js b/src/categories/index.js index 027913ccd9..9fc7479a69 100644 --- a/src/categories/index.js +++ b/src/categories/index.js @@ -5,7 +5,6 @@ const _ = require('lodash'); const db = require('../database'); const user = require('../user'); -const groups = require('../groups'); const plugins = require('../plugins'); const privileges = require('../privileges'); const cache = require('../cache'); From c241baf641d18ccc875d8d0583c64973b66cfc52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Mon, 30 Jan 2023 12:40:24 -0500 Subject: [PATCH 14/17] feat: closes #11241, add missing error lang keys --- public/language/en-GB/error.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/public/language/en-GB/error.json b/public/language/en-GB/error.json index 6cfc003e00..cd79886c34 100644 --- a/public/language/en-GB/error.json +++ b/public/language/en-GB/error.json @@ -70,6 +70,7 @@ "no-user": "User does not exist", "no-teaser": "Teaser does not exist", "no-flag": "Flag does not exist", + "no-chat-room": "Chat room does not exist", "no-privileges": "You do not have enough privileges for this action.", "category-disabled": "Category disabled", @@ -182,6 +183,9 @@ "chat-deleted-already": "This chat message has already been deleted.", "chat-restored-already": "This chat message has already been restored.", "chat-room-does-not-exist": "Chat room does not exist.", + "cant-add-users-to-chat-room": "Can't add users to chat room.", + "cant-remove-users-from-chat-room": "Can't remove users from chat room.", + "chat-room-name-too-long": "Chat room name too long.", "already-voting-for-this-post": "You have already voted for this post.", "reputation-system-disabled": "Reputation system is disabled.", From b5598a6e5d010e437bdc6c2ec87044a7a879a910 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Mon, 30 Jan 2023 15:05:57 -0500 Subject: [PATCH 15/17] fix: wrong link to topics in acp dashboard --- src/views/admin/dashboard/topics.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/admin/dashboard/topics.tpl b/src/views/admin/dashboard/topics.tpl index 98b86e5e8c..6c0951e654 100644 --- a/src/views/admin/dashboard/topics.tpl +++ b/src/views/admin/dashboard/topics.tpl @@ -17,7 +17,7 @@ {{{ end }}} {{{ each topics }}} - {../title} + {../title} [[topic:posted_by, {../user.username}]] From 705cd13ad3e983a5f020ac115403c4ce30eb69df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Tue, 31 Jan 2023 17:27:25 -0500 Subject: [PATCH 16/17] fix: closes #11249, notification uses displayname --- src/topics/scheduled.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/topics/scheduled.js b/src/topics/scheduled.js index 56c363db39..3544e54945 100644 --- a/src/topics/scheduled.js +++ b/src/topics/scheduled.js @@ -87,14 +87,15 @@ function unpin(tid, topicData) { } async function sendNotifications(uids, topicsData) { - const usernames = await Promise.all(uids.map(uid => user.getUserField(uid, 'username'))); - const uidToUsername = Object.fromEntries(uids.map((uid, idx) => [uid, usernames[idx]])); + const userData = await user.getUsersData(uids); + const uidToUserData = Object.fromEntries(uids.map((uid, idx) => [uid, userData[idx]])); - const postsData = await posts.getPostsData(topicsData.map(({ mainPid }) => mainPid)); + const postsData = await posts.getPostsData(topicsData.map(t => t && t.mainPid)); postsData.forEach((postData, idx) => { - postData.user = {}; - postData.user.username = uidToUsername[postData.uid]; - postData.topic = topicsData[idx]; + if (postData) { + postData.user = uidToUserData[topicsData[idx].uid]; + postData.topic = topicsData[idx]; + } }); return Promise.all(topicsData.map( From 202378b939a7279af7a39f597b7e75be3890deff Mon Sep 17 00:00:00 2001 From: nesro Date: Thu, 2 Feb 2023 14:19:45 +0100 Subject: [PATCH 17/17] fix: #11254, return check for reroll property --- src/controllers/authentication.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/authentication.js b/src/controllers/authentication.js index 2a006b321c..82dc6b1660 100644 --- a/src/controllers/authentication.js +++ b/src/controllers/authentication.js @@ -339,7 +339,7 @@ authenticationController.doLogin = async function (req, uid) { return; } const loginAsync = util.promisify(req.login).bind(req); - await loginAsync({ uid: uid }, { keepSessionInfo: req.res.locals !== false }); + await loginAsync({ uid: uid }, { keepSessionInfo: req.res.locals.reroll !== false }); await authenticationController.onSuccessfulLogin(req, uid); };