Complete the Notifications Flow (wire all lifecycle events)
Depends on: —
Task Description
The notifications module is partially wired. NotificationsService already has methods for created, funded, completed, evidence submitted, milestone approved, dispute opened, and dispute resolved. However, NotificationsListener only subscribes to 3 events (agreement.created, agreement.funded, agreement.completed), so several notification methods are effectively dead code — nothing triggers them end-to-end. This issue closes the gaps so every lifecycle event actually reaches the user.
Background / Current State
Verified against main:
- Dispute notifications not wired:
disputes.service.ts emits DISPUTE_OPENED and DISPUTE_RESOLVED, and the service has notifyDisputeOpened / notifyDisputeResolved, but NotificationsListener has no handlers for them.
- Evidence & milestone events never emitted:
notifyEvidenceSubmitted / notifyMilestoneApproved (and handleEvidenceSubmitted / handleMilestoneApproved) exist, but no code emits evidence_submitted or milestone_approved.
- Fragmented event constants:
AGREEMENT_EVENTS only defines CREATED/FUNDED/COMPLETED, while disputes use separate DISPUTE_OPENED/DISPUTE_RESOLVED constants in another file.
Deliverable
A fully wired event → listener → email flow covering all agreement lifecycle events.
Requirements
- Wire dispute notifications: add
@OnEvent handlers for DISPUTE_OPENED and DISPUTE_RESOLVED.
- Emit evidence/milestone events: emit
evidence_submitted and milestone_approved from the milestone update path in agreements.service.ts.
- Consolidate event constants: merge into one events constants source used by both agreements and disputes.
Validation System
- Opening a dispute sends the dispute-opened email; resolving sends dispute-resolved.
- Approving a milestone and submitting evidence each trigger their emails.
- Created/funded/completed continue to work (including the webhook-driven funded/completed path in
webhooks.service.ts).
- Listener failures are logged but do not crash the request (keep the existing try/catch pattern).
Technical Requirements
EventEmitterModule is already registered — reuse it; no new infra.
- Extend
NotificationsListener with the missing @OnEvent handlers.
- Emit missing events from the correct service methods (not from controllers).
- Update/extend
notifications.listener.spec.ts to cover the new handlers.
Additional Notes
Scope is wiring, not new templates — the email templates and service methods already exist. This is why emails "aren't arriving" for disputes/milestones today: the events are never delivered to the service.
Testing (required)
Proof of Completion (required)
Complete the Notifications Flow (wire all lifecycle events)
Depends on: —
Task Description
The notifications module is partially wired.
NotificationsServicealready has methods for created, funded, completed, evidence submitted, milestone approved, dispute opened, and dispute resolved. However,NotificationsListeneronly subscribes to 3 events (agreement.created,agreement.funded,agreement.completed), so several notification methods are effectively dead code — nothing triggers them end-to-end. This issue closes the gaps so every lifecycle event actually reaches the user.Background / Current State
Verified against
main:disputes.service.tsemitsDISPUTE_OPENEDandDISPUTE_RESOLVED, and the service hasnotifyDisputeOpened/notifyDisputeResolved, butNotificationsListenerhas no handlers for them.notifyEvidenceSubmitted/notifyMilestoneApproved(andhandleEvidenceSubmitted/handleMilestoneApproved) exist, but no code emitsevidence_submittedormilestone_approved.AGREEMENT_EVENTSonly definesCREATED/FUNDED/COMPLETED, while disputes use separateDISPUTE_OPENED/DISPUTE_RESOLVEDconstants in another file.Deliverable
A fully wired event → listener → email flow covering all agreement lifecycle events.
Requirements
@OnEventhandlers forDISPUTE_OPENEDandDISPUTE_RESOLVED.evidence_submittedandmilestone_approvedfrom the milestone update path inagreements.service.ts.Validation System
webhooks.service.ts).Technical Requirements
EventEmitterModuleis already registered — reuse it; no new infra.NotificationsListenerwith the missing@OnEventhandlers.notifications.listener.spec.tsto cover the new handlers.Additional Notes
Scope is wiring, not new templates — the email templates and service methods already exist. This is why emails "aren't arriving" for disputes/milestones today: the events are never delivered to the service.
Testing (required)
@OnEventhandler invokes the correct notification method.Proof of Completion (required)
notifications.listener.spec.ts).