v1.7.1: fix bot_test.html theme (localStorage key + css vars + scrollbar), mock MAX API for test users

This commit is contained in:
2026-05-29 08:27:57 +03:00
parent 54af5892d5
commit aa1269e013
5 changed files with 26 additions and 6 deletions
+3
View File
@@ -1,6 +1,8 @@
# Changelog — AegisOne MAX Bot
## 1.7.1 (29.05.2026)
### Новые функции
- **Тестовый прогон:** мок MAX API для test user_id (>=999999000) — сообщения не уходят в MAX
### Исправления
- **P1 (CRITICAL):** _add_column_if_not_exists — async def + await, миграции выполняются
- **P2 (CSS):** bot_consent, bot_tickets, bot_kb, bot_settings — var(--light-bg) → var(--bg-card), хардкод цвета → CSS-переменные
@@ -23,6 +25,7 @@
- **M4 (Double-load race):** settings_cache.py — asyncio.Lock
- **M5 (ORG regex):** захват полного ORG без обрезки по ;
- **M7 (bot_test.html):** тема наследуется через CSS-переменные + скрипт инициализации
- **bot_test.html:** исправлен ключ localStorage (theme → aegisone_service_theme), var(--bg-page) → var(--bg-body), добавлена стилизация скроллбара
- **L1 (Dead code):** _extract_name_from_vcf удалена
- **L2 (Импорты):** неиспользуемые Optional, json, config_reader удалены
- **L3 (.gitignore):** .opencode/, .env.example добавлены
+3 -3
View File
@@ -99,6 +99,8 @@ async def _add_column_if_not_exists(conn, table: str, column: str, col_type: str
END IF;
END $$;
"""))
except Exception as e:
logger.warning(f"Migration add column {table}.{column}: {e}")
def _validate_sql_name(name: str) -> None:
@@ -109,11 +111,9 @@ def _validate_sql_name(name: str) -> None:
def _validate_sql_type(col_type: str) -> None:
import re
allowed = r'^(VARCHAR\(\d+\)|TEXT|INTEGER|BOOLEAN( DEFAULT (TRUE|FALSE))?|TIMESTAMP)$'
allowed = r'^(VARCHAR\(\d+\)|TEXT|INTEGER( DEFAULT \d+)?|BOOLEAN( DEFAULT (TRUE|FALSE))?|TIMESTAMP)$'
if not re.match(allowed, col_type.strip()):
raise ValueError(f"Invalid SQL type: {col_type}")
except Exception as e:
logger.warning(f"Migration add column {table}.{column}: {e}")
async def _seed_default_settings():
+8
View File
@@ -1,7 +1,12 @@
import logging
import httpx
from typing import Optional
from app.config import settings
logger = logging.getLogger(__name__)
TEST_USER_THRESHOLD = 999999000
class MaxAPI:
def __init__(self):
@@ -58,6 +63,9 @@ class MaxAPI:
format: Optional[str] = None,
notify: bool = True,
) -> dict:
if user_id >= TEST_USER_THRESHOLD:
logger.info(f"MOCK send_message to test user {user_id}: {text[:50]}")
return {"ok": True, "mock": True}
payload = {"text": text, "notify": notify}
if attachments:
payload["attachments"] = attachments
+1
View File
@@ -2,6 +2,7 @@
## 1.7.1 (29.05.2026)
### Исправления
- **bot_test.html:** исправлен ключ localStorage для темы, var(--bg-page)→var(--bg-body), стилизация скроллбара
- **P2 (CSS):** bot_consent, bot_tickets, bot_kb, bot_settings — var(--light-bg)→var(--bg-card), хардкод цвета→CSS-переменные
- **M7 (bot_test.html):** тема наследуется через CSS-переменные + скрипт инициализации
- **C3 (Email typo):** contact proxy — user.email вместо user.phone
+11 -3
View File
@@ -6,13 +6,13 @@
<link rel="stylesheet" href="/static/css/service-theme.css">
<style>
* { margin:0; padding:0; box-sizing:border-box; }
body { font-family:'Inter','Segoe UI',sans-serif; background:var(--bg-page, #1B2838); color:var(--text-primary, #E8EDF2); font-size:13px; height:100vh; display:flex; flex-direction:column; }
body { font-family:'Inter','Segoe UI',sans-serif; background:var(--bg-body, #1B2838); color:var(--text-primary, #E8EDF2); font-size:13px; height:100vh; display:flex; flex-direction:column; }
.test-container { display:flex; flex:1; gap:12px; padding:12px; overflow:hidden; }
.test-chat { flex:1; border:1px solid var(--border, #253248); border-radius:10px; display:flex; flex-direction:column; overflow:hidden; }
.test-chat-header { background:var(--bg-card, #0A1628); padding:10px 14px; font-weight:600; border-bottom:1px solid var(--border, #253248); font-size:12px; }
.test-chat-messages { flex:1; overflow-y:auto; padding:10px 14px; }
.test-chat-input { display:flex; border-top:1px solid var(--border, #253248); }
.test-chat-input input { flex:1; border:none; padding:10px 14px; font-size:13px; outline:none; background:var(--bg-page, #1B2838); color:var(--text-primary, #E8EDF2); }
.test-chat-input input { flex:1; border:none; padding:10px 14px; font-size:13px; outline:none; background:var(--bg-body, #1B2838); color:var(--text-primary, #E8EDF2); }
.test-chat-input button { padding:10px 16px; border:none; background:var(--accent, #00ADEF); color:#fff; cursor:pointer; font-weight:600; }
.test-log { width:300px; border:1px solid var(--border, #253248); border-radius:10px; padding:10px; overflow-y:auto; font-family:monospace; font-size:11px; line-height:1.5; background:var(--bg-card, #0A1628); }
.test-log .log-entry { margin-bottom:4px; padding:3px 0; border-bottom:1px solid var(--border, #1e3044); }
@@ -23,9 +23,17 @@ body { font-family:'Inter','Segoe UI',sans-serif; background:var(--bg-page, #1B2
.test-scenarios { display:flex; gap:6px; padding:8px 12px; flex-wrap:wrap; border-bottom:1px solid var(--border, #253248); }
.test-scenarios button { font-size:11px; padding:4px 10px; background:var(--bg-input, #253248); color:var(--text-primary, #E8EDF2); border:1px solid var(--border, #3a4a60); border-radius:4px; cursor:pointer; }
.test-scenarios button:hover { background:var(--accent, #00ADEF); color:#fff; }
.test-log::-webkit-scrollbar { width:6px; }
.test-log::-webkit-scrollbar-track { background:var(--bg-body, #0D1B2A); border-radius:3px; }
.test-log::-webkit-scrollbar-thumb { background:var(--border, #253248); border-radius:3px; }
.test-log::-webkit-scrollbar-thumb:hover { background:var(--text-muted, #6B8299); }
.test-chat-messages::-webkit-scrollbar { width:6px; }
.test-chat-messages::-webkit-scrollbar-track { background:var(--bg-body, #0D1B2A); border-radius:3px; }
.test-chat-messages::-webkit-scrollbar-thumb { background:var(--border, #253248); border-radius:3px; }
.test-chat-messages::-webkit-scrollbar-thumb:hover { background:var(--text-muted, #6B8299); }
</style>
<script>
(function(){var t=localStorage.getItem('theme')||'dark';document.documentElement.setAttribute('data-theme',t);})();
(function(){function g(){return window.matchMedia('(prefers-color-scheme:light)').matches?'light':'dark'}var s=localStorage.getItem('aegisone_service_theme')||'system',r=s==='system'?g():s;document.documentElement.setAttribute('data-theme',r);})();
</script>
</head>
<body>