Skip to content

Add privacy preferences, message-state, and replication integration - #6

Merged
f8573 merged 2 commits into
mainfrom
pr6-privacy-message-replication
Jun 11, 2026
Merged

f8573 merged 2 commits into
mainfrom
pr6-privacy-message-replication

Conversation

@f8573

@f8573 f8573 commented Jun 11, 2026

Copy link
Copy Markdown
Owner

Summary

Adds the final core privacy, message-state, and replication integration slice.

Includes:

  • 000052_user_privacy_preferences migration
  • read receipt privacy gating
  • typing/presence privacy gating
  • read-status filtering by viewer preferences
  • privacy-aware replication for read checkpoints and typing events
  • LISTEN/NOTIFY-driven sync fanout with fallback polling
  • async ack waiter/subscriber path
  • explicit AsyncPipeline.Stop() shutdown ownership
  • presence connect/disconnect coverage for presence:user:<id>

Validation

  • go test ./internal/messages/...
  • go test ./internal/presence/...
  • go test ./internal/realtime/...
  • go test ./internal/replication/...
  • go build ./cmd/api ./cmd/worker

Notes

  • Privacy rows default permissive when absent, matching the opt-out sharing model.
  • pg_notify is paired with fallback polling, so missed notifications create bounded delay rather than data loss.
  • Cross-pod presence correctness still depends on existing Redis/session coordination.

f8573 and others added 2 commits June 10, 2026 23:43
Adds user_privacy_preferences table (migration 000052) and wires privacy
flags through read receipt write/read paths, typing indicator broadcast,
and presence visibility. Replaces polling-only SyncFanoutWorker with
pg_notify-driven wakeup; consolidates Redis ack to a single shared
subscription channel; refactors batch processing to bulk DB ops.

- Migration 000052: user_privacy_preferences (send_read_receipts,
  share_presence, share_typing) with permissive defaults
- messages/service: MarkRead gated by send_read_receipts;
  GetConversationReadStatus filters hidden receipts via LEFT JOIN
- realtime/ws: handleTypingSignal checks UserSharesTyping before
  broadcasting; drops Redis key when preference is false
- presence/service: GetUserPresenceForViewer viewer-aware filtering;
  share_presence=false suppresses Online and LastSeenAt
- replication/store: processReadCheckpoint and processTypingEvent check
  privacy flags in-transaction; AppendDomainEvent emits pg_notify
- worker/sync_fanout: LISTEN/NOTIFY driven with fallback polling;
  drainUntilEmpty loop replaces single-batch calls
- messages/async: single shared msg:ack:events subscription replaces
  per-event Redis subscriptions; in-process waiter map for WaitAck
- config: SyncFanoutBatchSize, SyncFanoutFallbackPoll,
  SyncFanoutNotifyChannel env-configurable

All gateway tests pass; build verified for cmd/api and cmd/worker.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@f8573
f8573 merged commit 52805e3 into main Jun 11, 2026
3 checks passed
f8573 added a commit that referenced this pull request Jun 11, 2026
* gateway: privacy prefs + read/typing/replication gating (PR 6)

Adds user_privacy_preferences table (migration 000052) and wires privacy
flags through read receipt write/read paths, typing indicator broadcast,
and presence visibility. Replaces polling-only SyncFanoutWorker with
pg_notify-driven wakeup; consolidates Redis ack to a single shared
subscription channel; refactors batch processing to bulk DB ops.

- Migration 000052: user_privacy_preferences (send_read_receipts,
  share_presence, share_typing) with permissive defaults
- messages/service: MarkRead gated by send_read_receipts;
  GetConversationReadStatus filters hidden receipts via LEFT JOIN
- realtime/ws: handleTypingSignal checks UserSharesTyping before
  broadcasting; drops Redis key when preference is false
- presence/service: GetUserPresenceForViewer viewer-aware filtering;
  share_presence=false suppresses Online and LastSeenAt
- replication/store: processReadCheckpoint and processTypingEvent check
  privacy flags in-transaction; AppendDomainEvent emits pg_notify
- worker/sync_fanout: LISTEN/NOTIFY driven with fallback polling;
  drainUntilEmpty loop replaces single-batch calls
- messages/async: single shared msg:ack:events subscription replaces
  per-event Redis subscriptions; in-process waiter map for WaitAck
- config: SyncFanoutBatchSize, SyncFanoutFallbackPoll,
  SyncFanoutNotifyChannel env-configurable

All gateway tests pass; build verified for cmd/api and cmd/worker.


* Harden privacy sync ack and presence lifecycle


---------
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.

1 participant