Role-Aware Notification Filter Service
Component Detail
Description
Service applying role-based visibility rules to the notification feed. Peer mentors see only their own notifications; coordinators additionally see notifications concerning their assigned peer mentors; org admins see all org-wide alerts. Encapsulates role logic so BLoC queries and filters correctly without leaking business rules into the UI layer.
role-aware-notification-filter
Summaries
The Role-Aware Notification Filter Service enforces the privacy and operational boundaries that make the notification system trustworthy and compliant. Without it, peer mentors could see coordinator-level alerts, or coordinators might miss notifications about their assigned mentees — both outcomes that undermine programme integrity and user confidence. By centralising role logic in one service rather than scattering it across the UI, the business ensures that any future role or permission change is applied consistently in a single place, dramatically reducing the risk of security gaps or inconsistent data exposure as the platform scales. This component is a key enabler for safely onboarding new user types or expanding the notification scope without regressions.
The Role-Aware Notification Filter Service is a medium-complexity component with a critical dependency on the notification repository for coordinator-scope resolution (fetching the list of peer mentors assigned to a coordinator). This introduces a database query path that must be tested under realistic data volumes to avoid performance regressions. The service must be delivered and stable before the Notification BLoC can be considered complete, since the BLoC delegates all filtering to it. Risk areas include the coordinator multi-peer-mentor scope: if the assignment model changes (e.g., coordinators gain or lose mentees dynamically), this service must be updated in lockstep.
Ensure the acceptance tests explicitly cover all three role scopes — peer mentor, coordinator, and org admin — with edge cases for empty mentor lists and mixed org membership.
Role-Aware Notification Filter Service exposes two complementary paths: buildQueryFilter(userId, UserRole) constructs Supabase PostgREST query predicates applied at fetch time, and filterNotifications(List
Both paths must produce identical visibility outcomes — divergence between query and in-memory filtering will cause phantom notifications appearing after realtime events that the initial query would have excluded.
Responsibilities
- Determine notification visibility scope based on user role
- Build Supabase query predicates for role-appropriate notification set
- Filter in-memory notification lists after realtime updates
- Support coordinator multi-peer-mentor scope resolution
- Ensure org admin receives org-wide alert notifications
Interfaces
buildQueryFilter(String userId, UserRole role)
filterNotifications(List<Notification>, UserRole, String userId)
isVisibleToUser(Notification, UserRole, String userId)
getCoordinatorPeerMentorIds(String coordinatorId)
isOrgWideAlert(NotificationType)
Relationships
Related Data Entities (3)
Data entities managed by this component