mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-13 18:02:21 +02:00
Merge branch 'master' into develop
This commit is contained in:
@@ -99,6 +99,10 @@ 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`);
|
||||
@@ -120,9 +124,14 @@ Categories.getModeratorUids = async function (cids) {
|
||||
const uniqGroups = _.uniq(_.flatten(sets.groupNames));
|
||||
const groupUids = await groups.getMembersOfGroups(uniqGroups);
|
||||
const map = _.zipObject(uniqGroups, groupUids);
|
||||
const moderatorUids = cids.map(
|
||||
(cid, index) => _.uniq(sets.uids[index].concat(_.flatten(sets.groupNames[index].map(g => map[g]))))
|
||||
);
|
||||
const moderatorUids = cids.map((cid, index) => {
|
||||
if (disabled[index]) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return _.uniq(sets.uids[index].concat(_.flatten(sets.groupNames[index].map(g => map[g]))));
|
||||
});
|
||||
console.log('what', moderatorUids);
|
||||
return moderatorUids;
|
||||
};
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ const cache = require('../cache');
|
||||
module.exports = function (Categories) {
|
||||
Categories.update = async function (modified) {
|
||||
const cids = Object.keys(modified);
|
||||
console.log('updating', cids);
|
||||
await Promise.all(cids.map(cid => updateCategory(cid, modified[cid])));
|
||||
return cids;
|
||||
};
|
||||
|
||||
@@ -32,6 +32,12 @@ try {
|
||||
if (!semver.satisfies(version, defaultPackage.dependencies[packageName])) {
|
||||
const e = new TypeError(`Incorrect dependency version: ${packageName}`);
|
||||
e.code = 'DEP_WRONG_VERSION';
|
||||
// delete the module from require cache so it doesn't break rest of the upgrade
|
||||
// https://github.com/NodeBB/NodeBB/issues/11173
|
||||
const resolvedModule = require.resolve(packageName);
|
||||
if (require.cache[resolvedModule]) {
|
||||
delete require.cache[resolvedModule];
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user