core/orm/reaction.py

46 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
2023-12-17 04:59:16 +00:00
from sqlalchemy import Column, ForeignKey, Integer, String
2023-11-22 16:38:39 +00:00
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
2024-04-17 15:32:23 +00:00
AGREE = "AGREE" # +1
DISAGREE = "DISAGREE" # -1
ASK = "ASK" # +0
PROPOSE = "PROPOSE" # +0
ACCEPT = "ACCEPT" # +1
REJECT = "REJECT" # -1
2023-11-27 16:03:47 +00:00
2024-04-09 11:03:50 +00:00
# expert mode
2024-04-17 15:32:23 +00:00
PROOF = "PROOF" # +1
DISPROOF = "DISPROOF" # -1
2024-04-09 11:03:50 +00:00
2023-11-27 16:03:47 +00:00
# public feed
2024-04-17 15:32:23 +00:00
QUOTE = "QUOTE" # +0 TODO: use to bookmark in collection
COMMENT = "COMMENT" # +0
LIKE = "LIKE" # +1
DISLIKE = "DISLIKE" # -1
2022-09-03 10:50:14 +00:00
class Reaction(Base):
2024-04-17 15:32:23 +00:00
__tablename__ = "reaction"
2023-10-23 14:47:11 +00:00
2024-04-17 15:32:23 +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()))
2024-04-17 15:32:23 +00:00
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)
reply_to = Column(ForeignKey("reaction.id"), nullable=True)
quote = Column(String, nullable=True, comment="Original quoted text")
shout = Column(ForeignKey("shout.id"), nullable=False)
created_by = Column(ForeignKey("author.id"), nullable=False)
2024-02-20 08:53:55 +00:00
kind = Column(String, nullable=False)
2023-11-22 16:38:39 +00:00
oid = Column(String)