Skip to content

Add webhook notifications for events (Issue #203)#501

Merged
filthyrake merged 2 commits intodevfrom
feature/203-webhook-notifications
Jan 4, 2026
Merged

Add webhook notifications for events (Issue #203)#501
filthyrake merged 2 commits intodevfrom
feature/203-webhook-notifications

Conversation

@filthyrake
Copy link
Copy Markdown
Owner

Summary

Implements a complete webhook notification system for external integrations as described in issue #203.

  • Database: New webhooks and webhook_deliveries tables with proper indices
  • API Endpoints: Full CRUD for webhooks, delivery history, and test functionality
  • Event Triggers: video.uploaded, video.ready, video.failed, video.deleted, video.restored
  • Security: HMAC-SHA256 payload signing, secrets never returned in responses
  • Reliability: Exponential backoff retry (up to 10 attempts), configurable via settings

Key Features

Webhook Configuration

  • Name, URL, subscribed events, optional HMAC secret
  • Custom headers support
  • Enable/disable without deletion

Event Triggers Integrated

  • video.uploaded - When new video is uploaded
  • video.ready - When transcoding completes successfully
  • video.failed - When transcoding permanently fails
  • video.deleted - When video is soft-deleted
  • video.restored - When video is restored from archive

Delivery System

  • Background worker processes pending deliveries every 5 seconds
  • Configurable retry with exponential backoff
  • Delivery statistics tracking (total/success/failure counts)
  • Full request/response logging for debugging

Settings (Database-backed)

  • webhooks.enabled - Enable/disable the system
  • webhooks.max_retries - Max delivery attempts (default: 5)
  • webhooks.retry_base_delay - Base delay in seconds (default: 30)
  • webhooks.request_timeout - HTTP timeout (default: 10s)

Test plan

  • Create a webhook subscription via POST /api/webhooks
  • Verify webhook appears in GET /api/webhooks list
  • Test webhook with POST /api/webhooks/{id}/test
  • Upload a video and verify video.uploaded webhook fires
  • Wait for transcoding and verify video.ready webhook fires
  • Delete video and verify video.deleted webhook fires
  • Check delivery history via GET /api/webhooks/{id}/deliveries
  • Test retry functionality for failed deliveries
  • Verify HMAC signature validation works on receiver end

Closes #203

🤖 Generated with Claude Code

filthyrake and others added 2 commits January 4, 2026 08:53
Implement a complete webhook notification system for external integrations:

Database:
- Add webhooks table for subscription configuration
- Add webhook_deliveries table for delivery history/retry tracking
- Migration 027_add_webhooks.py with proper indices

API Endpoints:
- GET/POST/PUT/DELETE /api/webhooks - CRUD for webhook subscriptions
- GET /api/webhooks/stats - System-wide delivery statistics
- POST /api/webhooks/{id}/test - Test webhook delivery
- GET /api/webhooks/{id}/deliveries - Delivery history
- POST /api/webhooks/{id}/deliveries/{id}/retry - Retry failed delivery

Webhook Service (api/webhook_service.py):
- HMAC-SHA256 payload signing for security
- Exponential backoff retry (configurable up to 10 attempts)
- Background delivery worker with configurable concurrency
- Rate-limited database updates

Supported Events:
- video.uploaded, video.ready, video.failed
- video.deleted, video.restored
- transcription.completed
- worker.registered, worker.offline

Settings (database-backed via settings_service.py):
- webhooks.enabled, max_retries, retry_base_delay
- retry_backoff_multiplier, request_timeout
- max_concurrent_deliveries, delivery_batch_size

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…bhooks

Security improvements:
- Add SSRF protection with blocked IP ranges (private networks, cloud metadata)
- Add header injection protection (protected headers list)
- Enforce minimum secret length (32 characters)
- Prevent URL redirects for SSRF protection

Reliability improvements:
- Add circuit breaker pattern for failing webhooks
- Add crash recovery for in-flight deliveries on startup
- Add worker health monitoring with heartbeat tracking
- Add graceful shutdown with configurable timeout
- Add jitter to exponential backoff to prevent thundering herd

Performance improvements:
- Use shared HTTP client with connection pooling
- Batch insert delivery records in single transaction
- Fix N+1 query pattern with bulk operations
- Use atomic SQL updates to prevent race conditions
- Add pagination to webhook list endpoint

New features:
- Add missing webhook triggers for transcription.completed, worker.registered, worker.offline
- Add automatic delivery history cleanup (configurable retention period)
- Add webhook worker status endpoint

Fixes Issue #203 review feedback.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@filthyrake filthyrake merged commit 81065ba into dev Jan 4, 2026
1 of 3 checks passed
@filthyrake filthyrake deleted the feature/203-webhook-notifications branch January 4, 2026 17:20
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.

Webhook notifications for events

1 participant