feat(api): cross-device upload activity endpoint + SSE #924
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/049-upload-activity-backend"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Spec 049 S2/S3/S7 (backend lane, tasks S049T001–T003).
Endpoint
GET /api/upload-activity— user-account scoped (created_by_user_id, ADR-0097): sessions with an active lifecycle status (receiving/commit_requested/committing) or updated within 24h, newest first, cap 20. Per session:GET /api/upload-sessions/{id}via the sharedUploadSessionService.SESSION_AGGREGATE_COLUMNSfragment (no drift).derivedStatusis derived: active + no update for 15 min →stale(interrupted upload, S6); completed(-with-issues) with files stillprocessing_queued→processing.receivingFileNames= files in received/classified/commit_pending, receive order, capped at 20/session.SSE
New
upload_activity_changedevent on the existing/api/events/stream, published after-commit viaServerEventPublisherat: session created, file received, file failed (unsupported receive), commit finished (full + per-file), batch completed. Payload is exactly{"sessionId": "..."}; the owning userAccountId is resolved from the session row and only that user's SSE stream receives it. Pre-staging rejections (payload too large) persist no file state and deliberately publish nothing.Schema
V145__upload_sessions_activity_index.sql: index onupload_sessions (created_by_user_id, updated_at DESC)— sessions have no expiry (ISSUE-060) while the feed is polled, so the recency branch gets an ordered path.Tests
UploadActivityTest(Testcontainers PostgreSQL, mirrorsUploadSessionOwnershipVerificationTest): aggregation (mixed states, ordering, 24h window, cap 20, name cap, ownership scoping incl. credential sessions), MockMvc contract (user + API-credential principal), and SSE assertions at each transition incl. after-commit deferral and no duplicate batch-completed event. Existing upload tests updated for the newUploadSessionService/UploadReceiveServiceconstructor params.Validation:
rtk ./gradlew :apps:api:test— 1342 tests, 0 failures/errors (9 skipped).Spec 049 S2/S3: GET /api/upload-activity returns the user account's active or 24h-recent upload sessions (newest first, cap 20) with per-session file counts aggregated by the same SQL as GET /api/upload-sessions/{id}, a derived status (stale/processing aware) and the file names currently awaiting commit. Publishes after-commit upload_activity_changed SSE events ({sessionId} payload only, owning userAccountId scoped) at session created, file received/failed, commit finished and batch completed. Adds V145 index on upload_sessions(created_by_user_id, updated_at) for the polled activity query.