Activity Flag Service
Component Detail
Service Layer
medium complexity
backend
2
Dependencies
2
Dependents
1
Entities
0
Integrations
Description
Core business logic service responsible for managing the full lifecycle of activity flag states. Handles flag creation with reason annotation, flag resolution that transitions activities back to pending review, and enforcement of role-based permission checks ensuring only coordinators and admins can flag or resolve. Writes to the flag_state enum column and flag_reason field on the activities table and records the flagged_by foreign key.
activity-flag-service
Responsibilities
- Set flag state (flagged, under_investigation, resolved) with mandatory reason
- Validate actor role permissions before any flag state transition
- Record flagged_by user reference and timestamp on state change
- Transition resolved activities back to pending_review for standard approval flow
- Emit audit log entries for every flag state change
Interfaces
flagActivity(activityId: string, reason: string, actorId: string): Promise<void>
resolveFlag(activityId: string, actorId: string): Promise<void>
getFlagHistory(activityId: string): Promise<FlagEvent[]>
getFlaggedActivities(orgId: string, filters: FlagFilter): Promise<PaginatedResult<Activity>>
Relationships
Dependencies (2)
Components this component depends on
Dependents (2)
Components that depend on this component