feat(admin): surface configuration problems in the admin panel
Add GET /api/admin/health powered by a config health service that detects common deployment mistakes: missing or read-only data volume, broken tariffs/locale-override/guides JSON files, payment providers enabled without credentials, webhook providers without WEBHOOK_BASE_URL, no enabled payment methods, missing or non-https mini app URL, missing Redis, partially configured SMTP, untrusted reverse proxy, invalid bot token, missing/mismatched/failing Telegram webhook and unreachable Remnawave panel. Network checks (Telegram, panel) are cached for two minutes; ?refresh=1 forces a re-check. The admin UI shows the alerts as a banner on the dashboard with per-section navigation chips and a manual re-check button, and as a filtered banner inside each affected section. Alerts are localized via admin_health_* keys with built-in Russian fallbacks.
This commit is contained in:
@@ -9,6 +9,7 @@ from bot.app.web.admin_api_impl import (
|
||||
backups as _backups,
|
||||
broadcast as _broadcast,
|
||||
common as _common,
|
||||
health as _health,
|
||||
logs as _logs,
|
||||
panel as _panel,
|
||||
payments as _payments,
|
||||
@@ -28,6 +29,7 @@ _MODULES = (
|
||||
_runtime,
|
||||
_auth,
|
||||
_common,
|
||||
_health,
|
||||
_stats,
|
||||
_users,
|
||||
_payments,
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# ruff: noqa: F401,F403,F405,I001
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from ._runtime import * # noqa: F403,F405
|
||||
from .auth import _require_admin_user_id
|
||||
from .common import _ok
|
||||
from bot.services.config_health_service import collect_config_alerts
|
||||
|
||||
|
||||
async def admin_health_route(request: web.Request) -> web.Response:
|
||||
_require_admin_user_id(request)
|
||||
refresh = str(request.query.get("refresh", "")).strip().lower() in {"1", "true", "yes"}
|
||||
alerts = await collect_config_alerts(request, refresh=refresh)
|
||||
return _ok(
|
||||
{
|
||||
"alerts": alerts,
|
||||
"checked_at": datetime.now(timezone.utc).isoformat(),
|
||||
}
|
||||
)
|
||||
@@ -6,6 +6,7 @@ def setup_admin_routes(app: web.Application) -> None:
|
||||
router = app.router
|
||||
router.add_get("/api/admin/me", admin_me_route)
|
||||
router.add_get("/api/admin/stats", admin_stats_route)
|
||||
router.add_get("/api/admin/health", admin_health_route)
|
||||
|
||||
router.add_get("/api/admin/users", admin_users_list_route)
|
||||
router.add_get("/api/admin/users/{user_id:-?\\d+}", admin_user_detail_route)
|
||||
|
||||
Reference in New Issue
Block a user