2023-09-06 18:02:47 +00:00
|
|
|
import time
|
|
|
|
|
2024-02-15 13:17:23 +00:00
|
|
|
from sqlalchemy import ForeignKey
|
|
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
2023-09-06 18:02:47 +00:00
|
|
|
from sqlalchemy.sql.sqltypes import *
|
|
|
|
|
|
|
|
from files.classes import Base
|
|
|
|
|
|
|
|
class UserMute(Base):
|
|
|
|
__tablename__ = "usermutes"
|
2024-02-15 13:17:23 +00:00
|
|
|
user_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
|
|
|
target_id: Mapped[int] = mapped_column(ForeignKey("users.id"), primary_key=True)
|
|
|
|
created_utc: Mapped[int]
|
2023-09-06 18:02:47 +00:00
|
|
|
|
2023-09-07 09:15:22 +00:00
|
|
|
user = relationship("User", primaryjoin="User.id==UserMute.user_id")
|
|
|
|
target = relationship("User", primaryjoin="User.id==UserMute.target_id")
|
|
|
|
|
2023-09-06 18:02:47 +00:00
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
|
|
|
|
super().__init__(*args, **kwargs)
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return f"<{self.__class__.__name__}(user={self.user_id}, target={self.target_id})>"
|