Files
core/orm/reaction.py

44 lines
1.3 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
from sqlalchemy import Column, Enum, ForeignKey, Integer, String
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
2022-09-19 16:50:43 +03:00
AGREE = 1 # +1
DISAGREE = 2 # -1
2023-11-27 19:03:47 +03:00
ASK = 3 # +0
PROPOSE = 4 # +0
PROOF = 5 # +1
DISPROOF = 6 # -1
ACCEPT = 7 # +1
REJECT = 8 # -1
# public feed
2023-11-27 21:18:52 +03:00
QUOTE = 9 # +0 TODO: use to bookmark in collection
2023-11-27 19:03:47 +03:00
COMMENT = 0 # +0
2022-09-19 16:50:43 +03:00
LIKE = 11 # +1
DISLIKE = 12 # -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()))
created_by = Column(ForeignKey("author.id"), nullable=False, index=True)
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)
2022-11-30 09:27:12 +03:00
shout = Column(ForeignKey("shout.id"), nullable=False, index=True)
2023-11-03 13:10:22 +03:00
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-10-23 17:47:11 +03:00
kind = Column(Enum(ReactionKind), nullable=False)
2023-11-22 19:38:39 +03:00
oid = Column(String)