core/orm/reaction.py

44 lines
1.3 KiB
Python
Raw Normal View History

2023-11-22 16:38:39 +00:00
import time
2022-09-19 13:50:43 +00:00
from enum import Enum as Enumeration
2023-11-22 16:38:39 +00:00
from sqlalchemy import Column, Enum, ForeignKey, Integer, String
2023-10-23 14:51:13 +00:00
from services.db import Base
2022-09-19 13:50:43 +00:00
class ReactionKind(Enumeration):
2023-11-27 16:03:47 +00:00
# TYPE = <reaction index> # rating diff
# editor mode
2022-09-19 13:50:43 +00:00
AGREE = 1 # +1
DISAGREE = 2 # -1
2023-11-27 16:03:47 +00:00
ASK = 3 # +0
PROPOSE = 4 # +0
PROOF = 5 # +1
DISPROOF = 6 # -1
ACCEPT = 7 # +1
REJECT = 8 # -1
# public feed
2023-11-27 18:18:52 +00:00
QUOTE = 9 # +0 TODO: use to bookmark in collection
2023-11-27 16:03:47 +00:00
COMMENT = 0 # +0
2022-09-19 13:50:43 +00:00
LIKE = 11 # +1
DISLIKE = 12 # -1
2022-09-03 10:50:14 +00:00
class Reaction(Base):
2022-09-03 10:50:14 +00:00
__tablename__ = "reaction"
2023-10-23 14:47:11 +00:00
2023-11-27 18:03:59 +00:00
body = Column(String, default='', comment="Reaction Body")
2023-11-03 10:10:22 +00: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 06:27:12 +00:00
shout = Column(ForeignKey("shout.id"), nullable=False, index=True)
2023-11-03 10:10:22 +00:00
reply_to = Column(ForeignKey("reaction.id"), nullable=True)
2023-11-27 16:03:47 +00:00
quote = Column(String, nullable=True, comment="Original quoted text")
2023-10-23 14:47:11 +00:00
kind = Column(Enum(ReactionKind), nullable=False)
2023-11-22 16:38:39 +00:00
oid = Column(String)