mirror of
https://github.com/bitwarden/directory-connector
synced 2025-12-13 06:43:16 +00:00
fix flatten
This commit is contained in:
@@ -56,7 +56,7 @@ export class SyncService {
|
|||||||
let users = entries[1];
|
let users = entries[1];
|
||||||
|
|
||||||
if (groups != null && groups.length > 0) {
|
if (groups != null && groups.length > 0) {
|
||||||
this.flattenUsersToGroups(groups, null, groups);
|
this.flattenUsersToGroups(groups, groups);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test || groups == null || groups.length === 0 || users == null || users.length === 0) {
|
if (test || groups == null || groups.length === 0 || users == null || users.length === 0) {
|
||||||
@@ -105,18 +105,15 @@ export class SyncService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private flattenUsersToGroups(currentGroups: GroupEntry[], currentGroupsUsers: string[], allGroups: GroupEntry[]) {
|
private flattenUsersToGroups(levelGroups: GroupEntry[], allGroups: GroupEntry[]): Set<string> {
|
||||||
for (const group of currentGroups) {
|
let allUsers = new Set<string>();
|
||||||
const groupsInThisGroup = allGroups.filter((g) => group.groupMemberReferenceIds.has(g.referenceId));
|
for (const group of levelGroups) {
|
||||||
let usersInThisGroup = Array.from(group.userMemberExternalIds);
|
const childGroups = allGroups.filter((g) => group.groupMemberReferenceIds.has(g.referenceId));
|
||||||
|
const childUsers = this.flattenUsersToGroups(childGroups, allGroups);
|
||||||
if (currentGroupsUsers != null) {
|
childUsers.forEach((id) => group.userMemberExternalIds.add(id));
|
||||||
currentGroupsUsers.forEach((id) => group.userMemberExternalIds.add(id));
|
allUsers = new Set([...allUsers, ...group.userMemberExternalIds]);
|
||||||
usersInThisGroup = usersInThisGroup.concat(currentGroupsUsers);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.flattenUsersToGroups(groupsInThisGroup, usersInThisGroup, allGroups);
|
|
||||||
}
|
}
|
||||||
|
return allUsers;
|
||||||
}
|
}
|
||||||
|
|
||||||
private getDirectoryService(): DirectoryService {
|
private getDirectoryService(): DirectoryService {
|
||||||
|
|||||||
Reference in New Issue
Block a user