mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 14:35:47 +01:00
fix: #7647, fix getModeratorUids
sets.groupNames is an array that contains other arrays of groupnames so passing it to getMembersOfGroups returned wrong results when there were more than 1 element in it.
This commit is contained in:
@@ -140,6 +140,7 @@ Categories.getModerators = function (cid, callback) {
|
||||
|
||||
Categories.getModeratorUids = function (cids, callback) {
|
||||
var sets;
|
||||
var uniqGroups;
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
var groupNames = cids.reduce(function (memo, cid) {
|
||||
@@ -162,11 +163,13 @@ Categories.getModeratorUids = function (cids, callback) {
|
||||
return memo;
|
||||
}, { groupNames: [], uids: [] });
|
||||
|
||||
groups.getMembersOfGroups(sets.groupNames, next);
|
||||
uniqGroups = _.uniq(_.flatten(sets.groupNames));
|
||||
groups.getMembersOfGroups(uniqGroups, next);
|
||||
},
|
||||
function (groupUids, next) {
|
||||
var map = _.zipObject(uniqGroups, groupUids);
|
||||
const moderatorUids = cids.map(function (cid, index) {
|
||||
return _.union(sets.uids[index].concat(groupUids[index]));
|
||||
return _.uniq(sets.uids[index].concat(_.flatten(sets.groupNames[index].map(g => map[g]))));
|
||||
});
|
||||
next(null, moderatorUids);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user