v1.7.0: refactor max_bot to flat structure, add VCF+UserModel+NLP history context, portal pages and proxy fixes
- Refactored max_bot from nested packages to flat module structure - Q2: Extended BotUser model (patronymic, email, org, address, vcf_raw, contact_hash, phone_verified, email_verified, last_interaction, total_conversations, total_tickets) - Q2: VCF parser (FN, N, TEL, EMAIL, ORG, ADR), upsert on re-contact, NLP history context (_get_user_history_context -> YandexGPT) - Q1: Broadcast preview modal with 10s confirmation timer - Q3: CSS var(--white)->var(--bg-card), var(--text)->var(--text-primary) - Q4: bot_settings showNotification(), editable max_bot_id - Q5: Webhook secret passthrough via X-Max-Bot-Api-Secret - Masking sensitive keys, dialog_cleared handler, migrate via _add_column_if_not_exists() - Rate limit (asyncio.sleep 0.5 per 10), dead code removed, conv.intent context in contact.py - Portal pages: bot_consent, bot_kb (edit), bot_settings, bot_test, bot_tickets, portal_settings - Tests: 21/21 passing, added test_yandex_gpt.py, test_email_sender.py - Deploy: deploy_full.sh, schema.sql, seed_knowledge_base.sql
This commit is contained in:
@@ -133,23 +133,6 @@ ROUTE_PERMISSIONS: dict[tuple[str, str], tuple[str, ...]] = {
|
||||
("POST", "/service/cases/edit"): ("owner",),
|
||||
("POST", "/service/cases/delete"): ("owner",),
|
||||
|
||||
# === BOT SETTINGS (pages) ===
|
||||
("GET", "/service/bot-settings"): ("owner",),
|
||||
("GET", "/service/bot-settings/responses"): ("owner",),
|
||||
("GET", "/service/bot-settings/features"): ("owner",),
|
||||
("GET", "/service/bot-settings/categories"): ("owner",),
|
||||
("GET", "/service/bot-settings/kb"): ("owner",),
|
||||
("GET", "/service/bot-settings/conversations"): ("owner",),
|
||||
("GET", "/service/bot-settings/users"): ("owner",),
|
||||
("GET", "/service/bot-settings/test-runner"): ("owner",),
|
||||
("GET", "/service/bot-settings/analytics"): ("owner",),
|
||||
("GET", "/service/bot-settings/risk-questions"): ("owner",),
|
||||
("GET", "/service/bot-settings/handoffs"): ("owner",),
|
||||
("GET", "/service/bot-settings/notifications"): ("owner",),
|
||||
("GET", "/service/bot-settings/broadcasts"): ("owner",),
|
||||
("GET", "/service/bot-settings/storage"): ("owner",),
|
||||
("GET", "/service/bot-settings/tickets"): ("owner",),
|
||||
|
||||
# === PORTAL / ROLE SETTINGS ===
|
||||
("GET", "/service/portal-settings"): ("owner",),
|
||||
("GET", "/service/role-settings"): ("owner",),
|
||||
@@ -162,57 +145,6 @@ ROUTE_PERMISSIONS: dict[tuple[str, str], tuple[str, ...]] = {
|
||||
("POST", "/service/api/role/switch"): ("owner", "engineer"),
|
||||
("POST", "/service/api/role/reset"): ("authenticated",),
|
||||
|
||||
# === BOT API (proxied) ===
|
||||
("GET", "/service/api/bot/settings"): ("owner",),
|
||||
("POST", "/service/api/bot/settings/save"): ("owner",),
|
||||
("GET", "/service/api/bot/templates"): ("owner",),
|
||||
("POST", "/service/api/bot/templates/save"): ("owner",),
|
||||
("GET", "/service/api/bot/features"): ("owner",),
|
||||
("POST", "/service/api/bot/features/toggle"): ("owner",),
|
||||
("GET", "/service/api/bot/categories"): ("owner",),
|
||||
("POST", "/service/api/bot/categories/create"): ("owner",),
|
||||
("POST", "/service/api/bot/categories/edit"): ("owner",),
|
||||
("POST", "/service/api/bot/categories/delete"): ("owner",),
|
||||
("GET", "/service/api/bot/kb"): ("owner",),
|
||||
("POST", "/service/api/bot/kb/create"): ("owner",),
|
||||
("POST", "/service/api/bot/kb/edit"): ("owner",),
|
||||
("POST", "/service/api/bot/kb/delete"): ("owner",),
|
||||
("GET", "/service/api/bot/conversations"): ("owner",),
|
||||
("GET", "/service/api/bot/users"): ("owner",),
|
||||
("GET", "/service/api/bot/analytics"): ("owner",),
|
||||
("POST", "/service/api/bot/test-run"): ("owner",),
|
||||
("GET", "/service/api/bot/broadcast/recipients"): ("owner",),
|
||||
("GET", "/service/api/bot/broadcast/history"): ("owner",),
|
||||
("POST", "/service/api/bot/broadcast"): ("owner",),
|
||||
|
||||
# === BOT RISK QUESTIONS ===
|
||||
("GET", "/service/api/bot/risk-questions"): ("owner",),
|
||||
("POST", "/service/api/bot/risk-questions/create"): ("owner",),
|
||||
("POST", "/service/api/bot/risk-questions/edit"): ("owner",),
|
||||
("POST", "/service/api/bot/risk-questions/toggle"): ("owner",),
|
||||
("POST", "/service/api/bot/risk-questions/delete"): ("owner",),
|
||||
|
||||
# === BOT STORAGE ===
|
||||
("GET", "/service/api/bot/storage/list"): ("owner",),
|
||||
("GET", "/service/api/bot/storage/search"): ("owner",),
|
||||
("GET", "/service/api/bot/storage/public-link"): ("owner",),
|
||||
("GET", "/service/api/bot/storage/download"): ("owner",),
|
||||
|
||||
# === BOT TICKETS ===
|
||||
("GET", "/service/api/bot/tickets"): ("owner",),
|
||||
("GET", "/service/api/bot/tickets/{ticket_id}"): ("owner",),
|
||||
("POST", "/service/api/bot/tickets/create"): ("owner",),
|
||||
("POST", "/service/api/bot/tickets/{ticket_id}/message"): ("owner",),
|
||||
("POST", "/service/api/bot/tickets/{ticket_id}/status"): ("owner",),
|
||||
("GET", "/service/api/bot/engineers"): ("owner",),
|
||||
|
||||
# === BOT HANDOFFS / NOTIFICATIONS (non-standard paths) ===
|
||||
("GET", "/service/bot-settings/handoffs/poll"): ("owner",),
|
||||
("POST", "/service/bot-settings/handoffs/{handoff_id}/take"): ("owner",),
|
||||
("POST", "/service/api/bot/handoffs/{handoff_id}/close"): ("owner",),
|
||||
("GET", "/service/bot-settings/notifications/data"): ("owner",),
|
||||
("POST", "/service/bot-settings/notifications/{notif_id}/read"): ("owner",),
|
||||
|
||||
# === OTHER API (main.py) ===
|
||||
("GET", "/service/api/shs"): ("owner", "engineer", "technician"),
|
||||
("GET", "/service/api/tasks"): ("owner", "engineer", "technician"),
|
||||
@@ -241,12 +173,6 @@ DYNAMIC_ROUTES: set[tuple[str, str]] = {
|
||||
("GET", "/service/documents/{slug}/edit"),
|
||||
("POST", "/service/documents/{slug}/edit"),
|
||||
("GET", "/service/documents/{slug}/download"),
|
||||
("POST", "/service/bot-settings/handoffs/{handoff_id}/take"),
|
||||
("POST", "/service/bot-settings/notifications/{notif_id}/read"),
|
||||
("POST", "/service/api/bot/handoffs/{handoff_id}/close"),
|
||||
("GET", "/service/api/bot/tickets/{ticket_id}"),
|
||||
("POST", "/service/api/bot/tickets/{ticket_id}/message"),
|
||||
("POST", "/service/api/bot/tickets/{ticket_id}/status"),
|
||||
}
|
||||
|
||||
# Routes excluded from discover test (internal framework routes)
|
||||
|
||||
@@ -36,15 +36,6 @@ PROTECTED_GET_ROUTES = [
|
||||
"/service/charts",
|
||||
"/service/portal-settings",
|
||||
"/service/role-settings",
|
||||
"/service/bot-settings",
|
||||
"/service/bot-settings/responses",
|
||||
"/service/bot-settings/features",
|
||||
"/service/bot-settings/categories",
|
||||
"/service/bot-settings/kb",
|
||||
"/service/bot-settings/conversations",
|
||||
"/service/bot-settings/users",
|
||||
"/service/bot-settings/test-runner",
|
||||
"/service/bot-settings/analytics",
|
||||
"/service/quick-menu",
|
||||
"/service/documents/",
|
||||
]
|
||||
@@ -56,16 +47,6 @@ API_GET_ROUTES = [
|
||||
"/service/api/quick-menu",
|
||||
"/service/api/role-permissions",
|
||||
"/service/api/charts/data",
|
||||
"/service/api/bot/settings",
|
||||
"/service/api/bot/templates",
|
||||
"/service/api/bot/features",
|
||||
"/service/api/bot/categories",
|
||||
"/service/api/bot/kb",
|
||||
"/service/api/bot/conversations",
|
||||
"/service/api/bot/users",
|
||||
"/service/api/bot/analytics",
|
||||
"/service/api/bot/broadcast/history",
|
||||
"/service/api/bot/broadcast/recipients",
|
||||
]
|
||||
|
||||
|
||||
@@ -151,24 +132,8 @@ class TestEngineerAccess:
|
||||
"/service/charts",
|
||||
"/service/portal-settings",
|
||||
"/service/role-settings",
|
||||
"/service/bot-settings",
|
||||
"/service/bot-settings/responses",
|
||||
"/service/bot-settings/features",
|
||||
"/service/bot-settings/categories",
|
||||
"/service/bot-settings/kb",
|
||||
"/service/bot-settings/users",
|
||||
"/service/bot-settings/test-runner",
|
||||
"/service/bot-settings/analytics",
|
||||
"/service/bot-settings/conversations",
|
||||
]
|
||||
|
||||
@pytest.mark.parametrize("path", ENGINEER_ALLOWED)
|
||||
def test_allowed(self, engineer_client, path):
|
||||
resp = engineer_client.get(path, follow_redirects=False)
|
||||
assert resp.status_code in (200, 302, 500), f"GET {path} returned {resp.status_code}"
|
||||
if resp.status_code == 500:
|
||||
pytest.fail(f"GET {path} returned 500 Internal Server Error")
|
||||
|
||||
@pytest.mark.parametrize("path", ENGINEER_FORBIDDEN)
|
||||
def test_forbidden(self, engineer_client, path):
|
||||
resp = engineer_client.get(path, follow_redirects=False)
|
||||
@@ -205,7 +170,6 @@ class TestTechnicianAccess:
|
||||
"/service/charts",
|
||||
"/service/portal-settings",
|
||||
"/service/role-settings",
|
||||
"/service/bot-settings",
|
||||
]
|
||||
|
||||
@pytest.mark.parametrize("path", TECHNICIAN_ALLOWED)
|
||||
@@ -239,14 +203,10 @@ class TestSidebarRoutes:
|
||||
"/service/incidents",
|
||||
"/service/checklist",
|
||||
"/service/documents/tech-access",
|
||||
"/service/bot-settings/analytics",
|
||||
"/service/bot-settings/users",
|
||||
"/service/bot-settings/conversations",
|
||||
"/service/blog",
|
||||
"/service/cases",
|
||||
"/service/questionnaire-config",
|
||||
"/service/formulas",
|
||||
"/service/bot-settings",
|
||||
"/service/portal-settings",
|
||||
"/service/role-settings",
|
||||
"/service/ideas",
|
||||
|
||||
@@ -86,42 +86,12 @@ EXPECTED_ROUTES = [
|
||||
("POST", "/service/cases/create"),
|
||||
("POST", "/service/cases/edit"),
|
||||
("POST", "/service/cases/delete"),
|
||||
("GET", "/service/bot-settings"),
|
||||
("GET", "/service/bot-settings/responses"),
|
||||
("GET", "/service/bot-settings/features"),
|
||||
("GET", "/service/bot-settings/categories"),
|
||||
("GET", "/service/bot-settings/kb"),
|
||||
("GET", "/service/bot-settings/conversations"),
|
||||
("GET", "/service/bot-settings/users"),
|
||||
("GET", "/service/bot-settings/test-runner"),
|
||||
("GET", "/service/bot-settings/analytics"),
|
||||
("GET", "/service/portal-settings"),
|
||||
("GET", "/service/role-settings"),
|
||||
("GET", "/service/api/role-permissions"),
|
||||
("POST", "/service/api/role-permissions/save"),
|
||||
("POST", "/service/api/role/switch"),
|
||||
("POST", "/service/api/role/reset"),
|
||||
("GET", "/service/api/bot/settings"),
|
||||
("POST", "/service/api/bot/settings/save"),
|
||||
("GET", "/service/api/bot/templates"),
|
||||
("POST", "/service/api/bot/templates/save"),
|
||||
("GET", "/service/api/bot/features"),
|
||||
("POST", "/service/api/bot/features/toggle"),
|
||||
("GET", "/service/api/bot/categories"),
|
||||
("POST", "/service/api/bot/categories/create"),
|
||||
("POST", "/service/api/bot/categories/edit"),
|
||||
("POST", "/service/api/bot/categories/delete"),
|
||||
("GET", "/service/api/bot/kb"),
|
||||
("POST", "/service/api/bot/kb/create"),
|
||||
("POST", "/service/api/bot/kb/edit"),
|
||||
("POST", "/service/api/bot/kb/delete"),
|
||||
("GET", "/service/api/bot/conversations"),
|
||||
("GET", "/service/api/bot/users"),
|
||||
("GET", "/service/api/bot/analytics"),
|
||||
("POST", "/service/api/bot/test-run"),
|
||||
("GET", "/service/api/bot/broadcast/recipients"),
|
||||
("GET", "/service/api/bot/broadcast/history"),
|
||||
("POST", "/service/api/bot/broadcast"),
|
||||
]
|
||||
|
||||
|
||||
@@ -159,14 +129,10 @@ class TestRoutesDefined:
|
||||
"/service/incidents",
|
||||
"/service/checklist",
|
||||
"/service/documents/tech-access",
|
||||
"/service/bot-settings/analytics",
|
||||
"/service/bot-settings/users",
|
||||
"/service/bot-settings/conversations",
|
||||
"/service/blog",
|
||||
"/service/cases",
|
||||
"/service/questionnaire-config",
|
||||
"/service/formulas",
|
||||
"/service/bot-settings",
|
||||
"/service/portal-settings",
|
||||
"/service/role-settings",
|
||||
"/service/ideas",
|
||||
|
||||
@@ -36,15 +36,6 @@ ROUTES_TO_CHECK = [
|
||||
"/service/formulas",
|
||||
"/service/coefficients",
|
||||
"/service/coefficients/test",
|
||||
"/service/bot-settings",
|
||||
"/service/bot-settings/responses",
|
||||
"/service/bot-settings/features",
|
||||
"/service/bot-settings/categories",
|
||||
"/service/bot-settings/kb",
|
||||
"/service/bot-settings/conversations",
|
||||
"/service/bot-settings/users",
|
||||
"/service/bot-settings/test-runner",
|
||||
"/service/bot-settings/analytics",
|
||||
"/service/portal-settings",
|
||||
"/service/role-settings",
|
||||
"/service/quick-menu",
|
||||
|
||||
Reference in New Issue
Block a user