@nostrclient_ext.websocket("/api/v1/relay")
async def ws_relay(websocket: WebSocket):
"""Relay multiplexer: one client (per endpoint) <-> multiple relays"""
await websocket.accept()
router = NostrRouter(websocket)
router.start()
while True:
await asyncio.sleep(10)
if not router.connected:
for s in router.subscriptions:
client.relay_manager.close_subscription(s)
router.stop()
break
Post-merge review. See comments to code also.
Is the code inside
/nostr
still needed?Refactor suggestions:
keep
views_api
for http/ws logic only. Move business logic functions (marshall_nostr_filters
,add_nostr_subscription
) intoservices.py
extract
NostrRouter