feat: Seaca mobile API, enrollment, FCM push and admin UI (0.9.0)
Adds mobile device registration by admin codes, refresh tokens, push channel in notification policy, and Settings section for managing Seaca clients. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -23,6 +23,11 @@ from app.services.notification_settings import (
|
||||
upsert_webhook_channel,
|
||||
)
|
||||
from app.services.telegram_notify import TelegramNotConfiguredError, TelegramSendError, send_telegram_test_message
|
||||
from app.services.webhook_notify import (
|
||||
WebhookNotConfiguredError,
|
||||
WebhookSendError,
|
||||
send_webhook_test_message,
|
||||
)
|
||||
from app.services.event_severity_overrides import (
|
||||
SOURCE_DB,
|
||||
list_severity_override_items,
|
||||
@@ -93,6 +98,7 @@ class NotificationPolicyResponse(BaseModel):
|
||||
use_telegram: bool
|
||||
use_webhook: bool
|
||||
use_email: bool
|
||||
use_mobile: bool
|
||||
source: str = Field(description="env или db")
|
||||
|
||||
|
||||
@@ -108,6 +114,7 @@ class NotificationPolicyUpdate(BaseModel):
|
||||
use_telegram: bool
|
||||
use_webhook: bool
|
||||
use_email: bool
|
||||
use_mobile: bool = False
|
||||
|
||||
|
||||
class TelegramSettingsUpdate(BaseModel):
|
||||
@@ -146,6 +153,7 @@ def _policy_to_response(cfg: NotificationPolicyConfig) -> NotificationPolicyResp
|
||||
use_telegram=cfg.use_telegram,
|
||||
use_webhook=cfg.use_webhook,
|
||||
use_email=cfg.use_email,
|
||||
use_mobile=cfg.use_mobile,
|
||||
source=cfg.source,
|
||||
)
|
||||
|
||||
@@ -212,7 +220,7 @@ def update_notification_policy(
|
||||
) -> NotificationPolicyResponse:
|
||||
if body.min_severity not in VALID_SEVERITIES:
|
||||
raise HTTPException(status_code=422, detail=f"min_severity must be one of: {sorted(VALID_SEVERITIES)}")
|
||||
if not any((body.use_telegram, body.use_webhook, body.use_email)):
|
||||
if not any((body.use_telegram, body.use_webhook, body.use_email, body.use_mobile)):
|
||||
raise HTTPException(status_code=422, detail="Выберите хотя бы один канал")
|
||||
try:
|
||||
policy = upsert_notification_policy(
|
||||
@@ -221,6 +229,7 @@ def update_notification_policy(
|
||||
use_telegram=body.use_telegram,
|
||||
use_webhook=body.use_webhook,
|
||||
use_email=body.use_email,
|
||||
use_mobile=body.use_mobile,
|
||||
)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=422, detail=str(exc)) from exc
|
||||
|
||||
Reference in New Issue
Block a user