30 lines
1.1 KiB
Python
30 lines
1.1 KiB
Python
from sqlalchemy import Column, Integer, String, DateTime, ForeignKey, Boolean, Text, Enum as SQLEnum
|
|
from sqlalchemy.orm import relationship
|
|
from datetime import datetime
|
|
import enum
|
|
from config.database import Base
|
|
|
|
class NotificationType(enum.Enum):
|
|
EVENT_INVITATION = "event_invitation"
|
|
EVENT_REMINDER = "event_reminder"
|
|
POST_MENTION = "post_mention"
|
|
NEW_ALBUM = "new_album"
|
|
NEW_VLOG = "new_vlog"
|
|
SYSTEM = "system"
|
|
|
|
class Notification(Base):
|
|
__tablename__ = "notifications"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
user_id = Column(Integer, ForeignKey("users.id"), nullable=False)
|
|
type = Column(SQLEnum(NotificationType), nullable=False)
|
|
title = Column(String, nullable=False)
|
|
message = Column(Text, nullable=False)
|
|
link = Column(String) # Link to the related content
|
|
is_read = Column(Boolean, default=False)
|
|
created_at = Column(DateTime, default=datetime.utcnow)
|
|
read_at = Column(DateTime, nullable=True)
|
|
|
|
# Relationships
|
|
user = relationship("User", back_populates="notifications")
|