Skip to content

feat(verification): stream inbox updates over SSE (#707) - #824

Open
Rayyanah0 wants to merge 1 commit into
Pulsefy:mainfrom
Rayyanah0:feat/707-sse-verification-inbox
Open

feat(verification): stream inbox updates over SSE (#707)#824
Rayyanah0 wants to merge 1 commit into
Pulsefy:mainfrom
Rayyanah0:feat/707-sse-verification-inbox

Conversation

@Rayyanah0

Copy link
Copy Markdown

Summary

Closes #707.

Add Server-Sent Events to the verification inbox so reviewer clients receive real-time queue mutations without aggressive polling.

Changes

New: VerificationInboxSseService

  • Singleton RxJS Subject-backed event bus
  • getStream(verificationId?) returns Observable<MessageEvent> — global or scoped to one request
  • emit(), buildStatusEvent(), buildNoteEvent() helpers
  • getConnectionCount() for observability
  • onModuleDestroy() completes the bus cleanly

New SSE endpoints on VerificationInboxController

Endpoint Scope
GET /api/v1/verification-inbox/events All inbox mutations
GET /api/v1/verification-inbox/:id/events Single verification request

Both require operator or admin role. Responses carry Cache-Control: no-cache and X-Accel-Buffering: no.

Event shapes

// status_updated
{ verificationId, timestamp, previousStatus, newStatus, reviewerId, rejectionReason?, nextStepMessage? }

// note_added
{ verificationId, timestamp, noteId, authorId, category? }

Wired into mutations

VerificationInboxService.updateStatus() and addInternalNote() emit SSE events after all DB writes complete.

Tests

  • 17 unit tests (verification-inbox-sse.service.spec.ts): message shape, multi-subscriber fan-out, scoped filtering, connection lifecycle, module destroy, reconnect no-replay
  • Updated verification-inbox.service.spec.ts: SSE mock wired in; asserts emit() is called with correct args
  • Integration tests (test/verification-inbox-sse.e2e-spec.ts): 401 without key, 200 + text/event-stream, status_updated for all three review actions, note_added shape, scoped isolation, reconnect no-replay, connection count tracking

Test results

Test Suites: 56 passed
Tests:       576 passed, 10 skipped (pre-existing)
Build:       clean
Lint:        clean

Acceptance criteria

  • SSE endpoint streams queue mutations and review updates
  • Connection lifecycle is authenticated and scoped
  • Tests verify message shape and reconnect behaviour

Add Server-Sent Events endpoint to the verification inbox so reviewer
clients can receive real-time queue mutations without polling.

## What changed

### New files
- verification-inbox-sse.service.ts — singleton SSE connection manager
  backed by an RxJS Subject. Provides getStream(verificationId?),
  emit(), buildStatusEvent(), buildNoteEvent(), getConnectionCount().
- verification-inbox-sse.service.spec.ts — 17 unit tests covering
  message shape, multi-subscriber broadcast, scoped filtering,
  connection lifecycle, module-destroy behaviour, and reconnect
  (no-replay) semantics.
- test/verification-inbox-sse.e2e-spec.ts — integration tests for
  the HTTP endpoint (401/200 + content-type), status_updated shape
  (approve/reject/needs_resubmission), note_added shape, scoped
  stream filtering, reconnect no-replay, and connection tracking.

### Modified files
- verification-inbox.controller.ts — two new @sse endpoints:
    GET /verification-inbox/events           (global feed)
    GET /verification-inbox/:id/events       (scoped to one request)
  Both require operator/admin role and set Cache-Control: no-cache.
- verification-inbox.service.ts — inject VerificationInboxSseService;
  call sseService.emit() at the end of updateStatus() and
  addInternalNote() after all DB writes complete.
- verification-inbox.service.spec.ts — add VerificationInboxSseService
  mock to the test module; add assertions for SSE emit calls.
- verification.module.ts — provide and export VerificationInboxSseService.

## Acceptance criteria
- SSE endpoint streams queue mutations and review updates. ✓
- Connection lifecycle is authenticated and scoped. ✓
- Tests verify message shape and reconnect behaviour. ✓
@drips-wave

drips-wave Bot commented Jul 25, 2026

Copy link
Copy Markdown

@Rayyanah0 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Cedarich

Copy link
Copy Markdown
Contributor

Kindly fix failing CI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stream Verification Inbox Updates Over SSE

2 participants