-
Notifications
You must be signed in to change notification settings - Fork 5
feat: Add support for d2:inUserGroup function[DHIS2-19426] #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM :)
(but I have forgotten a lot of details about the code 😂 )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this related to the rest of the PR? Seems the change from "USER_ROLES" to "USER" is another thing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change seems more aligned with the current update. The USER keyword was already being used for user roles, and now that we’re introducing USER_GROUPS, it makes sense to rename USER to USER_ROLES for better consistency and clarity.
| NamedFunction.d2_hasUserRole -> functions.d2_hasUserRole( | ||
| evalToString(fn.child(0)), | ||
| data.supplementaryValues["USER"]) | ||
| data.supplementaryValues["USER_ROLES"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will introduce a breaking change in the integrations. In the case of Android, this supplementaryValues property is passed by the Android app and it has the key USER (check this line in the Android app). I guess it would happen the same for the backend, @enricocolasante?
This change must be warned in the release notes. Or change, at least, the minor digit of the version instead of the patch one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clients will have to update to support USER_GROUPS this could also be the right opportunity to introduce the breaking change of renaming USER to USER_ROLES for better consistency. But if we all agree otherwise, then we can revert this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, we should add some warn somewhere and change the minor digit of the version.
I would also take the opportunity to make the supplementaryValues more explicit and structured and not rely on strings, so the breaking change would fail at compilation and it would be easier for the client fix it.
With the current change, rule-engine will continue to work but some strange behavior will happen around users and it is not really easy for the client to discover and understanding what is happening



https://dhis2.atlassian.net/browse/DHIS2-19426
PR implements
d2:inUserGroupfunction for program rule.d2:inUserGroup('UYXOT4A3SA')should return true if the current user is a member of this group "UYXOT4A3SA"