rDrama/files/classes/usermute.py

29 lines
845 B
Python
Raw Normal View History

import time
2024-02-15 13:17:23 +00:00
from typing import Optional, TYPE_CHECKING
2024-02-15 21:50:18 +00:00
from sqlalchemy.orm import Mapped, relationship
from sqlalchemy.sql.sqltypes import *
from files.classes import Base
2024-02-15 21:50:18 +00:00
from files.helpers.types import user_id_fk_pk
2024-02-15 13:17:23 +00:00
if TYPE_CHECKING:
from files.classes import User
class UserMute(Base):
__tablename__ = "usermutes"
2024-02-15 21:50:18 +00:00
user_id: Mapped[user_id_fk_pk]
target_id: Mapped[user_id_fk_pk]
2024-02-15 13:17:23 +00:00
created_utc: Mapped[Optional[int]]
2024-02-15 13:17:23 +00:00
user: Mapped["User"] = relationship(primaryjoin="User.id==UserMute.user_id")
target: Mapped["User"] = relationship(primaryjoin="User.id==UserMute.target_id")
2023-09-07 09:15:22 +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})>"