elmeg-demo/backend/helpers.py
fullsizemalt a4edbb676d
Some checks are pending
Deploy Elmeg / deploy (push) Waiting to run
feat(notifications): Added notification system with mention support
2025-12-21 02:36:02 -08:00

19 lines
751 B
Python

from sqlmodel import Session
from models import Notification
def create_notification(session: Session, user_id: int, title: str, message: str, type: str, link: str = None):
notification = Notification(
user_id=user_id,
title=title,
message=message,
type=type,
link=link
)
session.add(notification)
# Note: caller is responsible for commit if part of larger transaction,
# but for simple notification triggers, we can commit here or let caller do it.
# To be safe and atomic, usually we add to session and let caller commit.
# But for a helper, instant commit ensures specific notification persistence.
session.commit()
session.refresh(notification)
return notification