feat(verification): stream inbox updates over SSE (#707) - #824
Open
Rayyanah0 wants to merge 1 commit into
Open
Conversation
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. ✓
|
@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! 🚀 |
Contributor
|
Kindly fix failing CI |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #707.
Add Server-Sent Events to the verification inbox so reviewer clients receive real-time queue mutations without aggressive polling.
Changes
New:
VerificationInboxSseServiceSubject-backed event busgetStream(verificationId?)returnsObservable<MessageEvent>— global or scoped to one requestemit(),buildStatusEvent(),buildNoteEvent()helpersgetConnectionCount()for observabilityonModuleDestroy()completes the bus cleanlyNew SSE endpoints on
VerificationInboxControllerGET /api/v1/verification-inbox/eventsGET /api/v1/verification-inbox/:id/eventsBoth require operator or admin role. Responses carry
Cache-Control: no-cacheandX-Accel-Buffering: no.Event shapes
Wired into mutations
VerificationInboxService.updateStatus()andaddInternalNote()emit SSE events after all DB writes complete.Tests
verification-inbox-sse.service.spec.ts): message shape, multi-subscriber fan-out, scoped filtering, connection lifecycle, module destroy, reconnect no-replayverification-inbox.service.spec.ts: SSE mock wired in; assertsemit()is called with correct argstest/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 trackingTest results
Acceptance criteria