diff --git a/package.json b/package.json index ffecccfa..2395a5ed 100644 --- a/package.json +++ b/package.json @@ -75,5 +75,8 @@ }, "engines": { "node": "10.x" + }, + "volta": { + "node": "10.22.1" } } diff --git a/src/common/helper.js b/src/common/helper.js index 7eb3a96d..4d1e8abb 100644 --- a/src/common/helper.js +++ b/src/common/helper.js @@ -645,7 +645,7 @@ async function getUserGroups (userId) { headers: { Authorization: `Bearer ${token}` }, params: { page, - perPage: 1000, + perPage: 5000, memberId: userId, membershipType: 'user' } @@ -669,16 +669,15 @@ async function getUserGroups (userId) { * @returns {Promise} the user groups */ async function getCompleteUserGroupTreeIds (userId) { - const childGroups = await getUserGroups(userId) - const childGroupIds = _.map(childGroups, 'id') - let result = [] - for (const id of childGroupIds) { - if (!result.includes(id)) { - const expanded = await expandWithParentGroups(id) - result = _.concat(result, expanded) + const token = await getM2MToken() + const result = await axios.get(`${config.GROUPS_API_URL}/memberGroups/${userId}`, { + headers: { Authorization: `Bearer ${token}` }, + params: { + uuid: true } - } - return _.uniq(result) + }) + + return result.data || [] } /**