passing memberCount and createTime into getUserGroups

v1.18.x
Julian Lam 10 years ago
parent 4a7ec3ccc6
commit da0b2c84e6

@ -781,35 +781,51 @@ var async = require('async'),
groupData = groupData.filter(function(group) { groupData = groupData.filter(function(group) {
return parseInt(group.hidden, 10) !== 1 && !!group.userTitle; return parseInt(group.hidden, 10) !== 1 && !!group.userTitle;
}).map(function(group) {
group.createtimeISO = utils.toISOString(group.createtime);
return group;
}); });
var groupSets = groupData.map(function(group) { async.map(groupData, function(groupObj, next) {
group.labelColor = group.labelColor || '#000000'; Groups.getMemberCount(groupObj.name, function(err, memberCount) {
if (err) { return next(err); }
if (!group['cover:url']) { groupObj.memberCount = memberCount;
group['cover:url'] = nconf.get('relative_path') + '/images/cover-default.png'; next(err, groupObj);
group['cover:position'] = '50% 50%'; });
}, function(err, groupData) {
if (err) {
return callback(err);
} }
return 'group:' + group.name + ':members'; var groupSets = groupData.map(function(group) {
}); group.labelColor = group.labelColor || '#000000';
async.map(uids, function(uid, next) { if (!group['cover:url']) {
db.isMemberOfSortedSets(groupSets, uid, function(err, isMembers) { group['cover:url'] = nconf.get('relative_path') + '/images/cover-default.png';
if (err) { group['cover:position'] = '50% 50%';
return next(err);
} }
var memberOf = []; return 'group:' + group.name + ':members';
isMembers.forEach(function(isMember, index) { });
if (isMember) {
memberOf.push(groupData[index]); async.map(uids, function(uid, next) {
db.isMemberOfSortedSets(groupSets, uid, function(err, isMembers) {
if (err) {
return next(err);
} }
});
next(null, memberOf); var memberOf = [];
}); isMembers.forEach(function(isMember, index) {
}, callback); if (isMember) {
memberOf.push(groupData[index]);
}
});
next(null, memberOf);
});
}, callback);
});
}); });
}); });
}; };

Loading…
Cancel
Save