galaxis-po/backend/app/schemas/notification.py

51 lines
1.1 KiB
Python
Raw Permalink Normal View History

"""
Notification related Pydantic schemas.
"""
from datetime import datetime
from typing import Optional, List
from enum import Enum
from pydantic import BaseModel, Field
class ChannelType(str, Enum):
DISCORD = "discord"
TELEGRAM = "telegram"
class NotificationSettingCreate(BaseModel):
channel_type: ChannelType
webhook_url: str = Field(..., min_length=1, max_length=500)
enabled: bool = True
class NotificationSettingUpdate(BaseModel):
webhook_url: Optional[str] = Field(None, min_length=1, max_length=500)
enabled: Optional[bool] = None
class NotificationSettingResponse(BaseModel):
id: int
user_id: int
channel_type: str
webhook_url: str
enabled: bool
created_at: datetime
updated_at: datetime
class Config:
from_attributes = True
class NotificationHistoryResponse(BaseModel):
id: int
signal_id: int
channel_type: str
sent_at: datetime
status: str
message: Optional[str] = None
error_message: Optional[str] = None
class Config:
from_attributes = True