only return minimal info for pending and invited users

v1.18.x
Barış Soner Uşaklı
parent b840b96a4a
commit 4c0d430819

@ -121,10 +121,10 @@ Groups.get = function (groupName, options, callback) {
Groups.getOwnersAndMembers(groupName, options.uid, 0, stop, next); Groups.getOwnersAndMembers(groupName, options.uid, 0, stop, next);
}, },
pending: function (next) { pending: function (next) {
Groups.getUsersFromSet('group:' + groupName + ':pending', next); Groups.getUsersFromSet('group:' + groupName + ':pending', ['username', 'userslug', 'picture'], next);
}, },
invited: function (next) { invited: function (next) {
Groups.getUsersFromSet('group:' + groupName + ':invited', next); Groups.getUsersFromSet('group:' + groupName + ':invited', ['username', 'userslug', 'picture'], next);
}, },
isMember: async.apply(Groups.isMember, options.uid, groupName), isMember: async.apply(Groups.isMember, options.uid, groupName),
isPending: async.apply(Groups.isPending, options.uid, groupName), isPending: async.apply(Groups.isPending, options.uid, groupName),

@ -6,13 +6,21 @@ var db = require('../database');
var user = require('../user'); var user = require('../user');
module.exports = function (Groups) { module.exports = function (Groups) {
Groups.getUsersFromSet = function (set, callback) { Groups.getUsersFromSet = function (set, fields, callback) {
if (typeof fields === 'function') {
callback = fields;
fields = null;
}
async.waterfall([ async.waterfall([
function (next) { function (next) {
db.getSetMembers(set, next); db.getSetMembers(set, next);
}, },
function (uids, next) { function (uids, next) {
user.getUsersData(uids, next); if (fields) {
user.getUsersFields(uids, fields, callback);
} else {
user.getUsersData(uids, next);
}
}, },
], callback); ], callback);
}; };

Loading…
Cancel
Save