Add notif page
This commit is contained in:
35
models.py
35
models.py
@@ -262,4 +262,37 @@ class Event(db.Model):
|
||||
user = db.relationship('User', backref='events')
|
||||
|
||||
def __repr__(self):
|
||||
return f'<Event {self.event_type} by User {self.user_id} at {self.timestamp}>'
|
||||
return f'<Event {self.event_type} by User {self.user_id} at {self.timestamp}>'
|
||||
|
||||
class NotifType(Enum):
|
||||
# User notifications
|
||||
ACCOUNT_CREATED = 'account_created'
|
||||
PASSWORD_RESET = 'password_reset'
|
||||
ACCOUNT_DELETED = 'account_deleted'
|
||||
ACCOUNT_UPDATED = 'account_updated'
|
||||
|
||||
# Room notifications
|
||||
ROOM_INVITE = 'room_invite'
|
||||
ROOM_INVITE_REMOVED = 'room_invite_removed'
|
||||
|
||||
# Conversation notifications
|
||||
CONVERSATION_INVITE = 'conversation_invite'
|
||||
CONVERSATION_INVITE_REMOVED = 'conversation_invite_removed'
|
||||
CONVERSATION_MESSAGE = 'conversation_message'
|
||||
|
||||
class Notif(db.Model):
|
||||
__tablename__ = 'notifs'
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
notif_type = db.Column(db.String(50), nullable=False)
|
||||
user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
|
||||
sender_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=True)
|
||||
timestamp = db.Column(db.DateTime, default=datetime.utcnow, nullable=False)
|
||||
read = db.Column(db.Boolean, default=False, nullable=False)
|
||||
details = db.Column(db.JSON) # Store additional notification-specific data
|
||||
|
||||
# Relationships
|
||||
user = db.relationship('User', foreign_keys=[user_id], backref='notifications')
|
||||
sender = db.relationship('User', foreign_keys=[sender_id], backref='sent_notifications')
|
||||
|
||||
def __repr__(self):
|
||||
return f'<Notif {self.notif_type} for User {self.user_id} at {self.timestamp}>'
|
||||
Reference in New Issue
Block a user