Files
stellars-jupyterhub-ds/doc/notifications.md
stellarshenson 7ba01412d1 docs: simplify documentation to minimal modus primaris style
Drastically reduced documentation length focusing only on essential
implementation facts:

- doc/notifications.md: Reduced from 250 to 35 lines - key technical facts,
  handler implementation, template details, dependencies, error handling
- doc/ui-template-customization.md: Reduced from 132 to 55 lines - technical
  facts, JavaScript patterns, Bootstrap 5 syntax, CSRF protection, build process
- doc/docker-socket-permissions.md: Reduced from 186 to 66 lines - implementation
  facts, pre-spawn hook code, built-in group system, security implications, usage

All documentation now follows super-minimal "glimpse of implementation" approach
with bullet points and code snippets, absent of lengthy narrative and marketing
language.
2025-11-09 22:23:54 +01:00

1.9 KiB

Notification Broadcast System

Admin-only broadcast system sending notifications to all active JupyterLab servers simultaneously. Accessible at /hub/notifications.

Key Implementation Facts:

  • Concurrent delivery using asyncio.gather() with 5-second timeout per server
  • Temporary API tokens generated per broadcast (5-minute expiry via user.new_api_token())
  • Dynamic endpoint URL construction: http://jupyterlab-{username}:8888{base_url}jupyterlab-notifications-extension/ingest
  • 140-character message limit with live counter
  • Six notification types: default, info, success, warning, error, in-progress
  • Payload includes actions array with Dismiss button
  • One-line logging per server: username, message preview, type, outcome (SUCCESS/FAILED/ERROR)

Handler Implementation (services/jupyterhub/conf/bin/custom_handlers.py):

  • NotificationsPageHandler - Renders broadcast form at /hub/notifications
  • BroadcastNotificationHandler - API endpoint for sending notifications at /hub/api/notifications/broadcast
  • Both restricted to admin users via @admin_only decorator

Template (services/jupyterhub/templates/notifications.html):

  • Bootstrap 5 form with message textarea, type selector, auto-close toggle
  • RequireJS wrapped JavaScript for CSRF protection
  • Results display with expandable per-user status table

Dependencies:

Error Handling:

  • Connection timeout -> "Server not responding"
  • HTTP 404 -> "Notification extension not installed"
  • HTTP 401/403 -> "Authentication failed"
  • HTTP 500 -> "Server error processing notification"
  • Failures don't block other deliveries (fault-tolerant)