Groups.getGroupsAndMembers

v1.18.x
psychobunny 9 years ago
parent 5ff2eccbd2
commit 2516be620b

@ -80,28 +80,7 @@ var async = require('async'),
}); });
} }
async.parallel({ Groups.getGroupsAndMembers(groupNames, callback);
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);
});
} }
}; };
@ -109,6 +88,31 @@ var async = require('async'),
db.getSortedSetRevRange(set, start, stop, callback); 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) { Groups.get = function(groupName, options, callback) {
if (!groupName) { if (!groupName) {
return callback(new Error('[[error:invalid-group]]')); return callback(new Error('[[error:invalid-group]]'));

Loading…
Cancel
Save