From 4314be2978429c8a191ad26a958c4a2f5871b8f3 Mon Sep 17 00:00:00 2001 From: Ashfame Date: Wed, 22 Nov 2023 18:48:43 +0400 Subject: [PATCH] traverse on membership data endpoint pages to ensure entire membership list is collected --- src/TeamSyncer.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/TeamSyncer.ts b/src/TeamSyncer.ts index 07cd9af5..ef6982f9 100644 --- a/src/TeamSyncer.ts +++ b/src/TeamSyncer.ts @@ -444,13 +444,17 @@ export class TeamSyncer { existingMatrixUsersSet.add(u); } - const slackUsers = await client.conversations.members({channel: channelId}) as ConversationsMembersResponse; - await Promise.all( - slackUsers.members.map(async(slackUserId) => { - const ghost = await this.main.ghostStore.get(slackUserId, teamInfo.domain, teamId); - slackUsersSet.add(ghost.matrixUserId); - }) - ); + let cursor = ''; + do { + const slackUsers = await client.conversations.members({channel: channelId, limit: 1000, cursor}) as ConversationsMembersResponse; + await Promise.all( + slackUsers.members.map(async(slackUserId) => { + const ghost = await this.main.ghostStore.get(slackUserId, teamInfo.domain, teamId); + slackUsersSet.add(ghost.matrixUserId); + }) + ); + cursor = slackUsers.response_metadata.next_cursor; + } while (cursor !== ""); const joinedUsers: string[] = []; slackUsersSet.forEach((u) => {