|
|
@ -15,20 +15,23 @@ module.exports = function (Groups) {
|
|
|
|
async.waterfall([
|
|
|
|
async.waterfall([
|
|
|
|
async.apply(db.getSortedSetRange, 'groups:createtime', 0, -1),
|
|
|
|
async.apply(db.getSortedSetRange, 'groups:createtime', 0, -1),
|
|
|
|
function (groupNames, next) {
|
|
|
|
function (groupNames, next) {
|
|
|
|
// Ephemeral groups and the registered-users groups are searchable
|
|
|
|
if (!options.hideEphemeralGroups) {
|
|
|
|
groupNames = Groups.ephemeralGroups.concat(groupNames);
|
|
|
|
groupNames = Groups.ephemeralGroups.concat(groupNames);
|
|
|
|
|
|
|
|
}
|
|
|
|
groupNames = groupNames.filter(function (name) {
|
|
|
|
groupNames = groupNames.filter(function (name) {
|
|
|
|
return name.toLowerCase().includes(query) && name !== 'administrators' && !Groups.isPrivilegeGroup(name);
|
|
|
|
return name.toLowerCase().includes(query) && name !== 'administrators' && !Groups.isPrivilegeGroup(name);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
groupNames = groupNames.slice(0, 100);
|
|
|
|
groupNames = groupNames.slice(0, 100);
|
|
|
|
Groups.getGroupsData(groupNames, next);
|
|
|
|
if (options.showMembers) {
|
|
|
|
|
|
|
|
Groups.getGroupsAndMembers(groupNames, next);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Groups.getGroupsData(groupNames, next);
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
function (groupsData, next) {
|
|
|
|
function (groupsData, next) {
|
|
|
|
groupsData = groupsData.filter(Boolean);
|
|
|
|
groupsData = groupsData.filter(Boolean);
|
|
|
|
if (options.filterHidden) {
|
|
|
|
if (options.filterHidden) {
|
|
|
|
groupsData = groupsData.filter(function (group) {
|
|
|
|
groupsData = groupsData.filter(group => !group.hidden);
|
|
|
|
return !group.hidden;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Groups.sort(options.sort, groupsData, next);
|
|
|
|
Groups.sort(options.sort, groupsData, next);
|
|
|
|