You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
buzz-relay: extract validation/authorization logic into testable pure functions #24
Business logic in the relay handlers (side_effects.rs, ingest.rs, command_executor.rs) is embedded in functions that take &Arc<AppState>, mixing authorization checks with DB calls and notification emission. For example, handle_put_user does: parse event tags → check member role → validate last-owner → check channel_add_policy → call db.add_member → invalidate cache → emit system message → emit discovery events → emit notification. The ownership/role validation logic (last-owner guards, policy enforcement, role-change authorization) can be extracted into pure functions that take data parameters rather than &AppState, making them unit-testable without Postgres or Redis. Same validation is duplicated between WebSocket ingest and HTTP bridge paths. Priority: Medium — improves testability and removes duplication between transport paths.
🤖 AI review update (2026-08-23)
The goal is clear: make authorization decisions independently testable. Start with narrow pure decisions such as last-owner protection, role transitions, and channel-add policy, returning typed decisions/errors while keeping data loading and mutation orchestration outside. Correct the transport premise: HTTP POST /events already enters the same ingest_event path as WebSocket ingestion, so only proven duplication should be removed.
Activity
refactor(relay): extract NIP-29 membership authorization (#7285)
TheSentinel454 commentedon Sep 4, 2026
Completed by block#7285, merged at cd02b69.
refactor(relay): extract NIP-29 membership authorization (block#7285)
refactor(relay): extract NIP-29 membership authorization (block#7285)