Files
core/orm/reaction.py

44 lines
1.4 KiB
Python
Raw Normal View History

2023-11-22 19:38:39 +03:00
import time
2022-09-19 16:50:43 +03:00
from enum import Enum as Enumeration
2023-11-22 19:38:39 +03:00
2023-12-17 07:59:16 +03:00
from sqlalchemy import Column, ForeignKey, Integer, String
2023-11-22 19:38:39 +03:00
2023-10-23 17:51:13 +03:00
from services.db import Base
2022-09-19 16:50:43 +03:00
class ReactionKind(Enumeration):
2023-11-27 19:03:47 +03:00
# TYPE = <reaction index> # rating diff
# editor mode
2023-11-30 10:38:41 +03:00
AGREE = "AGREE" # +1
DISAGREE = "DISAGREE" # -1
ASK = "ASK" # +0
PROPOSE = "PROPOSE" # +0
PROOF = "PROOF" # +1
DISPROOF = "DISPROOF" # -1
ACCEPT = "ACCEPT" # +1
REJECT = "REJECT" # -1
2023-11-27 19:03:47 +03:00
# public feed
2023-11-30 10:38:41 +03:00
QUOTE = "QUOTE" # +0 TODO: use to bookmark in collection
COMMENT = "COMMENT" # +0
LIKE = "LIKE" # +1
DISLIKE = "DISLIKE" # -1
2022-09-03 13:50:14 +03:00
class Reaction(Base):
2022-09-03 13:50:14 +03:00
__tablename__ = "reaction"
2023-10-23 17:47:11 +03:00
2023-11-28 10:53:48 +03:00
body = Column(String, default="", comment="Reaction Body")
2023-11-03 13:10:22 +03:00
created_at = Column(Integer, nullable=False, default=lambda: int(time.time()))
updated_at = Column(Integer, nullable=True, comment="Updated at")
deleted_at = Column(Integer, nullable=True, comment="Deleted at")
deleted_by = Column(ForeignKey("author.id"), nullable=True, index=True)
reply_to = Column(ForeignKey("reaction.id"), nullable=True)
2023-11-27 19:03:47 +03:00
quote = Column(String, nullable=True, comment="Original quoted text")
2023-11-30 10:38:41 +03:00
shout = Column(ForeignKey("shout.id"), nullable=False, index=True)
created_by = Column(ForeignKey("author.id"), nullable=False, index=True)
2023-11-30 11:40:27 +03:00
kind = Column(String, nullable=False, index=True)
2023-11-22 19:38:39 +03:00
oid = Column(String)