Backend: - Add 2FA authentication with TOTP support - Add API keys management system - Add audit logging for security events - Add file upload/management system - Add notifications system with preferences - Add session management - Add webhooks integration - Add analytics endpoints - Add export functionality - Add password policy enforcement - Add new database migrations for core tables Frontend: - Add module position system (top/bottom sidebar sections) - Add search and notifications module configuration tabs - Add mobile logo replacing hamburger menu - Center page title absolutely when no tabs present - Align sidebar footer toggles with navigation items - Add lighter icon color in dark theme for mobile - Add API keys management page - Add notifications page with context - Add admin analytics and audit logs pages 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
64 lines
2.3 KiB
Python
64 lines
2.3 KiB
Python
"""Webhook model for external integrations."""
|
|
|
|
import uuid
|
|
from sqlalchemy import Column, String, Boolean, DateTime, Text, Integer, ForeignKey
|
|
from sqlalchemy.sql import func
|
|
|
|
from app.db.base import Base
|
|
|
|
|
|
class Webhook(Base):
|
|
"""Webhook configuration model."""
|
|
|
|
__tablename__ = "webhooks"
|
|
|
|
id = Column(String(36), primary_key=True, default=lambda: str(uuid.uuid4()))
|
|
name = Column(String(100), nullable=False)
|
|
url = Column(String(500), nullable=False)
|
|
secret = Column(String(64), nullable=True) # For signature verification
|
|
|
|
# Events to trigger on (JSON array stored as text)
|
|
events = Column(Text, nullable=False, default='["*"]') # ["user.created", "user.updated", etc.]
|
|
|
|
# Configuration
|
|
is_active = Column(Boolean, default=True, nullable=False)
|
|
retry_count = Column(Integer, default=3, nullable=False)
|
|
timeout_seconds = Column(Integer, default=30, nullable=False)
|
|
|
|
# Metadata
|
|
created_by = Column(String(36), ForeignKey("users.id", ondelete="SET NULL"), nullable=True)
|
|
created_at = Column(DateTime, server_default=func.now(), nullable=False)
|
|
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now(), nullable=False)
|
|
|
|
# Statistics
|
|
last_triggered_at = Column(DateTime, nullable=True)
|
|
success_count = Column(Integer, default=0, nullable=False)
|
|
failure_count = Column(Integer, default=0, nullable=False)
|
|
|
|
|
|
class WebhookDelivery(Base):
|
|
"""Webhook delivery log model."""
|
|
|
|
__tablename__ = "webhook_deliveries"
|
|
|
|
id = Column(String(36), primary_key=True, default=lambda: str(uuid.uuid4()))
|
|
webhook_id = Column(String(36), ForeignKey("webhooks.id", ondelete="CASCADE"), nullable=False)
|
|
|
|
# Event details
|
|
event_type = Column(String(50), nullable=False)
|
|
payload = Column(Text, nullable=False) # JSON payload
|
|
|
|
# Delivery status
|
|
status = Column(String(20), default="pending", nullable=False) # pending, success, failed
|
|
status_code = Column(Integer, nullable=True)
|
|
response_body = Column(Text, nullable=True)
|
|
error_message = Column(Text, nullable=True)
|
|
|
|
# Retry tracking
|
|
attempt_count = Column(Integer, default=0, nullable=False)
|
|
next_retry_at = Column(DateTime, nullable=True)
|
|
|
|
# Timestamps
|
|
created_at = Column(DateTime, server_default=func.now(), nullable=False)
|
|
delivered_at = Column(DateTime, nullable=True)
|