feat(invites): add group/channel invite links and join by token

This commit is contained in:
2026-03-08 09:58:55 +03:00
parent cc70394960
commit f01bbda14e
11 changed files with 247 additions and 6 deletions

View File

@@ -93,3 +93,17 @@ class ChatUserSetting(Base):
onupdate=func.now(),
nullable=False,
)
class ChatInviteLink(Base):
__tablename__ = "chat_invite_links"
__table_args__ = (
UniqueConstraint("token", name="uq_chat_invite_links_token"),
)
id: Mapped[int] = mapped_column(primary_key=True, index=True)
chat_id: Mapped[int] = mapped_column(ForeignKey("chats.id", ondelete="CASCADE"), nullable=False, index=True)
creator_user_id: Mapped[int] = mapped_column(ForeignKey("users.id", ondelete="CASCADE"), nullable=False, index=True)
token: Mapped[str] = mapped_column(String(64), nullable=False, index=True)
is_active: Mapped[bool] = mapped_column(Boolean, nullable=False, default=True, server_default="true")
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now(), nullable=False)