mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-12 08:55:47 +01:00
group join/leave controls in groups list page (+ helper!)
This commit is contained in:
@@ -71,7 +71,25 @@ var async = require('async'),
|
||||
groupNames = groupNames.concat(ephemeralGroups);
|
||||
|
||||
async.map(groupNames, function (groupName, next) {
|
||||
Groups.get(groupName, options, next);
|
||||
async.waterfall([
|
||||
async.apply(Groups.get, groupName, options),
|
||||
function(groupObj, next) {
|
||||
// Retrieve group membership state, if uid is passed in
|
||||
if (!options.uid) {
|
||||
return next(null, groupObj);
|
||||
}
|
||||
|
||||
Groups.isMember(options.uid, groupName, function(err, isMember) {
|
||||
if (err) {
|
||||
winston.warn('[groups.list] Could not determine membership in group `' + groupName + '` for uid `' + options.uid + '`: ' + err.message);
|
||||
return next(null, groupObj);
|
||||
}
|
||||
|
||||
groupObj.isMember = isMember;
|
||||
next(null, groupObj);
|
||||
});
|
||||
}
|
||||
], next);
|
||||
}, function (err, groups) {
|
||||
callback(err, internals.filterGroups(groups, options));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user