notifier/orm/reaction.py

44 lines
1.3 KiB
Python
Raw Normal View History

2023-11-23 22:58:55 +00:00
import time
from enum import Enum as Enumeration
from sqlalchemy import Column, Enum, ForeignKey, Integer, String
from services.db import Base
class ReactionKind(Enumeration):
2023-11-27 16:03:17 +00:00
# TYPE = <reaction index> # rating diff
# editor mode
2023-11-23 22:58:55 +00:00
AGREE = 1 # +1
DISAGREE = 2 # -1
2023-11-27 16:03:17 +00:00
ASK = 3 # +0
PROPOSE = 4 # +0
PROOF = 5 # +1
DISPROOF = 6 # -1
ACCEPT = 7 # +1
REJECT = 8 # -1
# public feed
QUOTE = 9 # +0 bookmark
COMMENT = 0 # +0
2023-11-23 22:58:55 +00:00
LIKE = 11 # +1
DISLIKE = 12 # -1
class Reaction(Base):
__tablename__ = "reaction"
body = Column(String, nullable=True, comment="Reaction Body")
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)
shout = Column(ForeignKey("shout.id"), nullable=False, index=True)
reply_to = Column(ForeignKey("reaction.id"), nullable=True)
2023-11-27 16:03:17 +00:00
quote = Column(String, nullable=True, comment="Original quoted text")
2023-11-23 22:58:55 +00:00
kind = Column(Enum(ReactionKind), nullable=False)
oid = Column(String)