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
|
2023-11-30 07:38:41 +00: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 16:03:47 +00:00
|
|
|
|
|
|
|
# public feed
|
2023-11-30 07:38:41 +00:00
|
|
|
QUOTE = "QUOTE" # +0 TODO: use to bookmark in collection
|
|
|
|
COMMENT = "COMMENT" # +0
|
|
|
|
LIKE = "LIKE" # +1
|
|
|
|
DISLIKE = "DISLIKE" # -1
|
2022-07-21 11:58:50 +00:00
|
|
|
|
2022-09-03 10:50:14 +00:00
|
|
|
|
2022-07-21 11:58:50 +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-28 07:53:48 +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()))
|
|
|
|
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 16:03:47 +00:00
|
|
|
quote = Column(String, nullable=True, comment="Original quoted text")
|
2023-11-30 07:38:41 +00:00
|
|
|
shout = Column(ForeignKey("shout.id"), nullable=False, index=True)
|
|
|
|
created_by = Column(ForeignKey("author.id"), nullable=False, index=True)
|
|
|
|
kind = Column(Enum(ReactionKind), nullable=False, index=True)
|
2023-11-22 16:38:39 +00:00
|
|
|
|
|
|
|
oid = Column(String)
|