fix: return groups user has access to in group payloads #3613
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
General Checklist
Database Migrations
As identified in uselagoon/lagoon-cli#288 (comment) Users in groups with multiple roles (eg owner, developer etc) may not be able to view their project-group allocations via the cli, because the checks performed in Lagoon don't manage to marry the user groups and project groups successfully. This will manifest as the following:
When we changed the group payload to use brief representation, this meant more information was returned in the response than what is generated when a user requests their groups. This meant that the intersection that was previously performed would fail because the project group could contain all the subgroups for roles, and the user groups would only contain the group they are a member of within the main group, the intersection would fail as the two objects were now different.
This PR changes the comparison done to still match on the parent group even if the subgroups are not all returned in a user groups query.