Add webhook notifications for events (Issue #203)#501
Merged
filthyrake merged 2 commits intodevfrom Jan 4, 2026
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements a complete webhook notification system for external integrations as described in issue #203.
webhooksandwebhook_deliveriestables with proper indicesKey Features
Webhook Configuration
Event Triggers Integrated
video.uploaded- When new video is uploadedvideo.ready- When transcoding completes successfullyvideo.failed- When transcoding permanently failsvideo.deleted- When video is soft-deletedvideo.restored- When video is restored from archiveDelivery System
Settings (Database-backed)
webhooks.enabled- Enable/disable the systemwebhooks.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
Closes #203
🤖 Generated with Claude Code