Files
Messenger/app/notifications/schemas.py

40 lines
918 B
Python

from datetime import datetime
from typing import Any
from pydantic import BaseModel, ConfigDict, Field
class NotificationRequest(BaseModel):
user_id: int
event_type: str
payload: dict
class NotificationRead(BaseModel):
model_config = ConfigDict(from_attributes=True)
id: int
user_id: int
event_type: str
payload: str
created_at: datetime
class PushTaskPayload(BaseModel):
user_id: int
title: str
body: str
data: dict[str, Any]
class PushTokenUpsertRequest(BaseModel):
platform: str = Field(min_length=2, max_length=16)
token: str = Field(min_length=8, max_length=512)
device_id: str | None = Field(default=None, max_length=128)
app_version: str | None = Field(default=None, max_length=64)
class PushTokenDeleteRequest(BaseModel):
platform: str = Field(min_length=2, max_length=16)
token: str = Field(min_length=8, max_length=512)