mirror of
https://github.com/elisiariocouto/leggen.git
synced 2025-12-13 13:42:19 +00:00
- Change filters config from nested dict to simple arrays - Update NotificationFilters model to use List[str] instead of Dict[str, str] - Modify notification service to handle list-based filters - Update API routes and tests for new format - Update README with new configuration example Before: [filters.case-insensitive] salary = 'salary' After: [filters] case-insensitive = ['salary', 'utility']
54 lines
1.2 KiB
Python
54 lines
1.2 KiB
Python
from typing import Optional, List
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class DiscordConfig(BaseModel):
|
|
"""Discord notification configuration"""
|
|
|
|
webhook: str
|
|
enabled: bool = True
|
|
|
|
|
|
class TelegramConfig(BaseModel):
|
|
"""Telegram notification configuration"""
|
|
|
|
token: str
|
|
chat_id: int
|
|
enabled: bool = True
|
|
|
|
|
|
class NotificationFilters(BaseModel):
|
|
"""Notification filters configuration"""
|
|
|
|
case_insensitive: List[str] = []
|
|
case_sensitive: Optional[List[str]] = None
|
|
amount_threshold: Optional[float] = None
|
|
keywords: List[str] = []
|
|
|
|
|
|
class NotificationSettings(BaseModel):
|
|
"""Complete notification settings"""
|
|
|
|
discord: Optional[DiscordConfig] = None
|
|
telegram: Optional[TelegramConfig] = None
|
|
filters: NotificationFilters = NotificationFilters()
|
|
|
|
|
|
class NotificationTest(BaseModel):
|
|
"""Test notification request"""
|
|
|
|
service: str # "discord" or "telegram"
|
|
message: str = "Test notification from Leggen"
|
|
|
|
|
|
class NotificationHistory(BaseModel):
|
|
"""Notification history entry"""
|
|
|
|
id: str
|
|
service: str
|
|
message: str
|
|
status: str # "sent", "failed"
|
|
sent_at: str
|
|
error: Optional[str] = None
|