mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-03 20:45:58 +01:00
Groups.getGroupsAndMembers
This commit is contained in:
@@ -80,28 +80,7 @@ var async = require('async'),
|
||||
});
|
||||
}
|
||||
|
||||
async.parallel({
|
||||
groups: function(next) {
|
||||
Groups.getGroupsData(groupNames, next);
|
||||
},
|
||||
members: function(next) {
|
||||
Groups.getMemberUsers(groupNames, 0, 3, next);
|
||||
}
|
||||
}, function (err, data) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
data.groups.forEach(function(group, index) {
|
||||
if (!group) {
|
||||
return;
|
||||
}
|
||||
Groups.escapeGroupData(group);
|
||||
group.members = data.members[index] || [];
|
||||
group.truncated = group.memberCount > data.members.length;
|
||||
});
|
||||
|
||||
callback(null, data.groups);
|
||||
});
|
||||
Groups.getGroupsAndMembers(groupNames, callback);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -109,6 +88,31 @@ var async = require('async'),
|
||||
db.getSortedSetRevRange(set, start, stop, callback);
|
||||
};
|
||||
|
||||
Groups.getGroupsAndMembers = function(groupNames, callback) {
|
||||
async.parallel({
|
||||
groups: function(next) {
|
||||
Groups.getGroupsData(groupNames, next);
|
||||
},
|
||||
members: function(next) {
|
||||
Groups.getMemberUsers(groupNames, 0, 3, next);
|
||||
}
|
||||
}, function (err, data) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
data.groups.forEach(function(group, index) {
|
||||
if (!group) {
|
||||
return;
|
||||
}
|
||||
Groups.escapeGroupData(group);
|
||||
group.members = data.members[index] || [];
|
||||
group.truncated = group.memberCount > data.members.length;
|
||||
});
|
||||
|
||||
callback(null, data.groups);
|
||||
});
|
||||
};
|
||||
|
||||
Groups.get = function(groupName, options, callback) {
|
||||
if (!groupName) {
|
||||
return callback(new Error('[[error:invalid-group]]'));
|
||||
|
||||
Reference in New Issue
Block a user