Skip to content

Commit

Permalink
Merge pull request #26 from Automattic/team_sync_membership_fix
Browse files Browse the repository at this point in the history
Fix membership sync
  • Loading branch information
ashfame authored Nov 23, 2023
2 parents 4983799 + 4314be2 commit 8fe9837
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/TeamSyncer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit 8fe9837

Please sign in to comment.