notifier/orm/notification.py
2023-11-24 01:58:55 +03:00

33 lines
817 B
Python

from enum import Enum as Enumeration
import time
from sqlalchemy import Boolean, Column, Enum, Integer
from sqlalchemy.dialects.postgresql import JSONB
from services.db import Base
class NotificationEntity(Enumeration):
REACTION = 1
SHOUT = 2
FOLLOWER = 3
class NotificationAction(Enumeration):
CREATE = 1
UPDATE = 2
DELETE = 3
SEEN = 4
FOLLOW = 5
UNFOLLOW = 6
class Notification(Base):
__tablename__ = "notification"
created_at = Column(Integer, default=lambda: int(time.time()))
seen = Column(Boolean, nullable=False, default=False, index=True)
entity = Column(Enum(NotificationEntity), nullable=False)
action = Column(Enum(NotificationAction), nullable=False)
payload = Column(JSONB, nullable=True)
# occurrences = Column(Integer, default=1)