Files
vidconf/backend/models/webhook_event.py

26 lines
1021 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Модель для идемпотентной обработки webhook-событий LiveKit."""
from datetime import datetime
from sqlalchemy import DateTime, String, func
from sqlalchemy.orm import Mapped, mapped_column
from models.base import Base
class LivekitWebhookEvent(Base):
"""Журнал полученных webhook-событий LiveKit.
`event_id` — первичный ключ; повторная доставка того же события
(`INSERT ... ON CONFLICT DO NOTHING`) отклоняется на уровне БД в одной
транзакции с эффектами обработчика (см. `api/livekit_webhook.py`).
"""
__tablename__ = "livekit_webhook_events"
event_id: Mapped[str] = mapped_column(String(255), primary_key=True)
event_type: Mapped[str] = mapped_column(String(64), nullable=False)
received_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True), nullable=False, server_default=func.now()
)