""" In-app notification service. Creates notification records for the notification centre. Separate from ntfy push — in-app notifications are always created; ntfy push is gated by per-type toggles. """ from typing import Optional from sqlalchemy.ext.asyncio import AsyncSession from app.models.notification import Notification async def create_notification( db: AsyncSession, user_id: int, type: str, title: str, message: str, data: Optional[dict] = None, source_type: Optional[str] = None, source_id: Optional[int] = None, ) -> Notification: """Create an in-app notification. Does NOT commit — caller handles transaction.""" notification = Notification( user_id=user_id, type=type, title=title, message=message, data=data, source_type=source_type, source_id=source_id, ) db.add(notification) return notification