import uuid from datetime import datetime from sqlalchemy import DateTime, ForeignKey, String, func from sqlalchemy.orm import Mapped, mapped_column, relationship from app.models.base import Base class WebhookIncoming(Base): __tablename__ = "webhooks_incoming" id: Mapped[uuid.UUID] = mapped_column(primary_key=True, default=uuid.uuid4) room_id: Mapped[uuid.UUID] = mapped_column(ForeignKey("rooms.id"), index=True, nullable=False) # Stored in the clear (not hashed) -- the whole point is the room admin # can view/copy the full webhook URL again anytime, unlike an API token. token: Mapped[str] = mapped_column(String(64), unique=True, index=True, nullable=False) created_by: Mapped[uuid.UUID] = mapped_column(ForeignKey("users.id"), nullable=False) description: Mapped[str | None] = mapped_column(String(500)) created_at: Mapped[datetime] = mapped_column( DateTime(timezone=True), server_default=func.now(), nullable=False ) room = relationship("Room") creator = relationship("User")