From 1e6031e182c5d2ff30864f5d44eec5d5d1c7d342 Mon Sep 17 00:00:00 2001 From: Frieder Schrempf Date: Fri, 20 Oct 2023 21:21:49 +0200 Subject: [PATCH] ctservice.js: Avoid global group membership endpoint alltogether --- src/ctservice.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/ctservice.js b/src/ctservice.js index e85ee6d..93eb8b1 100644 --- a/src/ctservice.js +++ b/src/ctservice.js @@ -178,18 +178,17 @@ exports.getChurchToolsData = async (site) => { }); } - if (allGroupsIds) { - log.info('Get Person IDs of Group Members from ChurchTools'); - ctPersonIds = await this.getPersonsInGroups(site); - } - log.info('Get Groups from ChurchTools'); const ctGroups = await this.getGroups(allGroupsIds, site); + log.info('Get Group Memberships from ChurchTools'); + const ctGroupIds = ctGroups.map((group) => group.id); + const ctGroupMembership = await this.getGroupMemberships(ctGroupIds, site); log.info('Get Person Details from ChurchTools'); + if (allGroupsIds != null) { + ctPersonIds = ctGroupMembership.map((member) => member.id); + ctPersonIds = Array.from(new Set(ctPersonIds)); + } const ctPersons = await this.getPersons(ctPersonIds, site); - log.info('Get Group Memberships from ChurchTools'); - const groupIds = ctGroups.map((group) => group.id); - const ctGroupMembership = await this.getGroupMemberships(groupIds, site); return { groups: ctGroups,