Bug/epmedu 4891 fix moderators inconsistency#294
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Pull Request overview
Fix assigned moderators inconsistency — align with backend relations and ensure correct role-based updates
Problem
Assigned moderators were displayed inconsistently on the Feeding Point Details screen.
Root cause: the implementation relied on indirect data sources (feeding history) and lacked a proper connection to backend user-group relations.
Summary
This PR introduces a dedicated Moderation Directory service and fixes moderator resolution logic to use backend relations directly.
Changes include:
Root Cause Analysis
1) Incorrect data source (Feeding history)
The previous implementation extracted moderators from:
FeedingHistory.assignedModeratorsThis approach is unreliable because:
Correct behavior requires using:
FeedingPoint.users2) Missing backend integration for moderators
There was no dedicated mechanism to fetch:
This prevented proper filtering and mapping of assigned users.
Solution:
ModerationDirectoryServiceto fetch users from Cognito groups:ModeratorAdministrator3) Role synchronization issues
User roles were not always up-to-date:
Fix:
signedIneventcognito:groupsclaims are used4) UI update timing and async inconsistencies
Moderators were:
Fixes:
moderatorsTaskupdateModerators()with proper lifecycle handlingMainActorChanges
ModerationDirectoryServiceto dependency containerupdateModerators()and async task handling🧠 How it works (High level)
App fetches moderators/admins from Cognito via AdminQueries API
FeedingPoint relations (
users) provide assigned user IDsService filters only assigned moderators/admins
Names are mapped and passed to UI
UI updates only when:
Token refresh ensures roles are always up-to-date
How to test
Assigned moderators display
Role-based visibility
Login as:
Verify role updates across sessions:
Dynamic updates
Session refresh