From 4c0d4308192d754d51ef4f9a0b831cb2f64ca81d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 15 Sep 2017 17:07:43 -0400 Subject: [PATCH] only return minimal info for pending and invited users --- src/groups.js | 4 ++-- src/groups/user.js | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/groups.js b/src/groups.js index ed96f415b0..3ac8f36914 100644 --- a/src/groups.js +++ b/src/groups.js @@ -121,10 +121,10 @@ Groups.get = function (groupName, options, callback) { Groups.getOwnersAndMembers(groupName, options.uid, 0, stop, next); }, pending: function (next) { - Groups.getUsersFromSet('group:' + groupName + ':pending', next); + Groups.getUsersFromSet('group:' + groupName + ':pending', ['username', 'userslug', 'picture'], 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), isPending: async.apply(Groups.isPending, options.uid, groupName), diff --git a/src/groups/user.js b/src/groups/user.js index fb524a87b9..c959add132 100644 --- a/src/groups/user.js +++ b/src/groups/user.js @@ -6,13 +6,21 @@ var db = require('../database'); var user = require('../user'); 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([ function (next) { db.getSetMembers(set, next); }, function (uids, next) { - user.getUsersData(uids, next); + if (fields) { + user.getUsersFields(uids, fields, callback); + } else { + user.getUsersData(uids, next); + } }, ], callback); };