Skip to content

Commit

Permalink
Ignore GDPR trained status for members on non manage account groups
Browse files Browse the repository at this point in the history
  • Loading branch information
Oscariremma committed Nov 13, 2024
1 parent 5c35778 commit 2ad3134
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public AccountScaffoldFacade(

/**
* Get all super groups that have the provided types and their "sub" groups with their members.
* For groups that require managed accounts, only users that have participated in gdpr training are included.
*/
public List<AccountScaffoldSuperGroupDTO> getActiveSuperGroups() {
this.accessGuard.require(isApi(ApiKeyType.ACCOUNT_SCAFFOLD));
Expand All @@ -62,7 +63,9 @@ public List<AccountScaffoldSuperGroupDTO> getActiveSuperGroups() {
group -> {
List<AccountScaffoldUserPostDTO> activeGroupMember =
group.groupMembers().stream()
.filter(groupMember -> gdprTrained.contains(groupMember.user().id()))
.filter(groupMember ->
gdprTrained.contains(groupMember.user().id()) ||
!isGroupWithManagedAccounts(group, settings))
.map(AccountScaffoldUserPostDTO::new)
.toList();

Expand Down Expand Up @@ -107,13 +110,7 @@ public List<AccountScaffoldUserDTO> getActiveUsers() {
this.apiKeySettingsRepository.getAccountScaffoldSettings(apiAuthentication.get().id());

return this.groupRepository.getAll().stream()
.filter(
group ->
settings.superGroupTypes().stream()
.anyMatch(
row ->
(row.type().equals(group.superGroup().type()))
&& row.requiresManaged()))
.filter(group -> isGroupWithManagedAccounts(group, settings))
.flatMap(group -> group.groupMembers().stream())
.map(GroupMember::user)
.distinct()
Expand Down Expand Up @@ -211,5 +208,13 @@ private SuperGroupWithGroups(SuperGroup superGroup, List<GroupWithMembers> group
}
}

private boolean isGroupWithManagedAccounts(Group group, ApiKeyAccountScaffoldSettings settings) {
return settings.superGroupTypes().stream()
.anyMatch(
row ->
row.type().equals(group.superGroup().type())
&& row.requiresManaged());
}


}

0 comments on commit 2ad3134

Please sign in to comment.