fix: auto-fix code issues (cron)
- 修复重复导入/字段 - 修复异常处理 (将裸 except Exception 改为具体异常类型) - 修复PEP8格式问题 - 清理未使用导入 - 添加 UUID_LENGTH 常量替代魔法数字 - 添加 DEFAULT_RATE_LIMIT, MASTER_KEY_RATE_LIMIT, IP_RATE_LIMIT 常量 - 添加 MAX_TEXT_LENGTH, DEFAULT_TIMEOUT 常量 涉及文件: - backend/main.py - backend/db_manager.py - backend/llm_client.py - backend/neo4j_manager.py - backend/tingwu_client.py - backend/tenant_manager.py - backend/growth_manager.py - backend/workflow_manager.py - backend/image_processor.py - backend/multimodal_entity_linker.py - backend/multimodal_processor.py - backend/plugin_manager.py - backend/rate_limiter.py
This commit is contained in:
@@ -11,7 +11,6 @@ import json
|
||||
import os
|
||||
import sqlite3
|
||||
import time
|
||||
import urllib.parse
|
||||
import uuid
|
||||
from dataclasses import dataclass, field
|
||||
from datetime import datetime
|
||||
@@ -20,6 +19,9 @@ from typing import Any
|
||||
|
||||
import httpx
|
||||
|
||||
# Constants
|
||||
UUID_LENGTH = 8 # UUID 截断长度
|
||||
|
||||
# WebDAV 支持
|
||||
try:
|
||||
import webdav4.client as webdav_client
|
||||
@@ -318,7 +320,7 @@ class PluginManager:
|
||||
)
|
||||
config_id = existing["id"]
|
||||
else:
|
||||
config_id = str(uuid.uuid4())[:8]
|
||||
config_id = str(uuid.uuid4())[:UUID_LENGTH]
|
||||
conn.execute(
|
||||
"""INSERT INTO plugin_configs
|
||||
(id, plugin_id, config_key, config_value, is_encrypted, created_at, updated_at)
|
||||
@@ -400,7 +402,7 @@ class ChromeExtensionHandler:
|
||||
expires_days: int = None,
|
||||
) -> ChromeExtensionToken:
|
||||
"""创建 Chrome 扩展令牌"""
|
||||
token_id = str(uuid.uuid4())[:8]
|
||||
token_id = str(uuid.uuid4())[:UUID_LENGTH]
|
||||
|
||||
# 生成随机令牌
|
||||
raw_token = f"if_ext_{base64.urlsafe_b64encode(os.urandom(32)).decode('utf-8').rstrip('=')}"
|
||||
@@ -563,7 +565,7 @@ class ChromeExtensionHandler:
|
||||
return {"success": False, "error": "Insufficient permissions"}
|
||||
|
||||
# 创建转录记录(将网页作为文档处理)
|
||||
transcript_id = str(uuid.uuid4())[:8]
|
||||
transcript_id = str(uuid.uuid4())[:UUID_LENGTH]
|
||||
now = datetime.now().isoformat()
|
||||
|
||||
# 构建完整文本
|
||||
@@ -604,7 +606,7 @@ class BotHandler:
|
||||
secret: str = "",
|
||||
) -> BotSession:
|
||||
"""创建机器人会话"""
|
||||
bot_id = str(uuid.uuid4())[:8]
|
||||
bot_id = str(uuid.uuid4())[:UUID_LENGTH]
|
||||
now = datetime.now().isoformat()
|
||||
|
||||
conn = self.pm.db.get_conn()
|
||||
@@ -932,7 +934,7 @@ class WebhookIntegration:
|
||||
trigger_events: list[str] = None,
|
||||
) -> WebhookEndpoint:
|
||||
"""创建 Webhook 端点"""
|
||||
endpoint_id = str(uuid.uuid4())[:8]
|
||||
endpoint_id = str(uuid.uuid4())[:UUID_LENGTH]
|
||||
now = datetime.now().isoformat()
|
||||
|
||||
conn = self.pm.db.get_conn()
|
||||
@@ -1155,7 +1157,7 @@ class WebDAVSyncManager:
|
||||
sync_interval: int = 3600,
|
||||
) -> WebDAVSync:
|
||||
"""创建 WebDAV 同步配置"""
|
||||
sync_id = str(uuid.uuid4())[:8]
|
||||
sync_id = str(uuid.uuid4())[:UUID_LENGTH]
|
||||
now = datetime.now().isoformat()
|
||||
|
||||
conn = self.pm.db.get_conn()
|
||||
|
||||
Reference in New Issue
Block a user