Activity Flag Service
Component Detail
Description
Backend service exposing REST endpoints POST /api/v1/activities/:id/flags and PATCH /api/v1/activities/:id/flags/:flagId for flag creation and resolution. Enforces authorization so only org admins and coordinators within the activity's organization can flag or resolve. Triggers notification dispatch to the peer mentor and coordinator when a flag is created.
activity-flag-service
Sources & reasoning
Core business logic layer required to persist and lifecycle-manage flags, enforce the reason code enum, and apply org-scoped authorization. The distributed multi-level org structure (NHF: 1 400 local chapters) means regional coordinators flag for national admins to resolve, making service-layer authorization enforcement essential for correctness.
No source references — this artifact was included based on reasoning alone (see above).
Responsibilities
- Create activity flag records with reason code, comment, flagged_by, and timestamp
- Validate reason code against the controlled enum before persisting
- Resolve flags by writing resolved_at and resolved_by fields
- Enforce org-scoped authorization via role guard before any flag mutation
- Dispatch flag-created notification events to relevant users
Interfaces
createFlag(activityId, reasonCode, comment, flaggedBy): Flag
resolveFlag(flagId, resolvedBy): Flag
listFlags(activityId): Flag[]
getFlaggedActivities(orgId, filters): PaginatedActivities