core/orm/notification.py

26 lines
847 B
Python
Raw Normal View History

from datetime import datetime
from sqlalchemy import Column, Enum, ForeignKey, DateTime, Boolean, Integer
from sqlalchemy.dialects.postgresql import JSONB
2022-08-11 05:53:14 +00:00
from base.orm import Base
from enum import Enum as Enumeration
class NotificationType(Enumeration):
2023-10-11 08:56:46 +00:00
NEW_REACTION = 1
NEW_SHOUT = 2
NEW_FOLLOWER = 3
2022-09-03 10:50:14 +00:00
class Notification(Base):
2022-09-03 10:50:14 +00:00
__tablename__ = "notification"
shout = Column(ForeignKey("shout.id"), index=True)
reaction = Column(ForeignKey("reaction.id"), index=True)
user = Column(ForeignKey("user.id"), index=True)
createdAt = Column(DateTime, nullable=False, default=datetime.now, index=True)
seen = Column(Boolean, nullable=False, default=False, index=True)
type = Column(Enum(NotificationType), nullable=False)
data = Column(JSONB, nullable=True)
occurrences = Column(Integer, default=1)