@@ -41,6 +41,7 @@ public AccountScaffoldFacade(
4141
4242 /**
4343 * Get all super groups that have the provided types and their "sub" groups with their members.
44+ * For groups that require managed accounts, only users that have participated in gdpr training are included.
4445 */
4546 public List <AccountScaffoldSuperGroupDTO > getActiveSuperGroups () {
4647 this .accessGuard .require (isApi (ApiKeyType .ACCOUNT_SCAFFOLD ));
@@ -62,7 +63,9 @@ public List<AccountScaffoldSuperGroupDTO> getActiveSuperGroups() {
6263 group -> {
6364 List <AccountScaffoldUserPostDTO > activeGroupMember =
6465 group .groupMembers ().stream ()
65- .filter (groupMember -> gdprTrained .contains (groupMember .user ().id ()))
66+ .filter (groupMember ->
67+ gdprTrained .contains (groupMember .user ().id ()) ||
68+ !isGroupWithManagedAccounts (group , settings ))
6669 .map (AccountScaffoldUserPostDTO ::new )
6770 .toList ();
6871
@@ -107,13 +110,7 @@ public List<AccountScaffoldUserDTO> getActiveUsers() {
107110 this .apiKeySettingsRepository .getAccountScaffoldSettings (apiAuthentication .get ().id ());
108111
109112 return this .groupRepository .getAll ().stream ()
110- .filter (
111- group ->
112- settings .superGroupTypes ().stream ()
113- .anyMatch (
114- row ->
115- (row .type ().equals (group .superGroup ().type ()))
116- && row .requiresManaged ()))
113+ .filter (group -> isGroupWithManagedAccounts (group , settings ))
117114 .flatMap (group -> group .groupMembers ().stream ())
118115 .map (GroupMember ::user )
119116 .distinct ()
@@ -211,5 +208,13 @@ private SuperGroupWithGroups(SuperGroup superGroup, List<GroupWithMembers> group
211208 }
212209 }
213210
211+ private boolean isGroupWithManagedAccounts (Group group , ApiKeyAccountScaffoldSettings settings ) {
212+ return settings .superGroupTypes ().stream ()
213+ .anyMatch (
214+ row ->
215+ row .type ().equals (group .superGroup ().type ())
216+ && row .requiresManaged ());
217+ }
218+
214219
215220}
0 commit comments