feat: 飞书机器人按租户路由 群组绑定租户 + 独立凭证 + 知识库隔离
1. 新增 resolve_tenant_by_chat_id() 根据飞书群 chat_id 查找绑定的租户 2. 新增 get_tenant_feishu_config() 获取租户级飞书凭证 3. FeishuService 支持传入自定义 app_id/app_secret(租户级别) 4. feishu_bot.py 收到消息时自动解析租户,使用租户凭证回复 5. feishu_longconn_service.py 同样按 chat_id 解析租户并传递 tenant_id 6. 租户管理 UI 新增飞书配置字段:App ID、App Secret、绑定群 Chat ID 7. 租户列表展示飞书绑定状态和群数量 8. 保存租户时同步更新飞书配置到 config JSON
This commit is contained in:
@@ -137,6 +137,11 @@ class FeishuLongConnService:
|
||||
|
||||
logger.info(f"🔑 会话标识: {session_user_id}")
|
||||
|
||||
# 解析租户:根据 chat_id 查找绑定的租户
|
||||
from src.web.blueprints.tenants import resolve_tenant_by_chat_id
|
||||
tenant_id = resolve_tenant_by_chat_id(chat_id)
|
||||
logger.info(f"🏢 群 {chat_id} 对应租户: {tenant_id}")
|
||||
|
||||
# 获取或创建会话
|
||||
chat_manager = service_manager.get_chat_manager()
|
||||
active_sessions = chat_manager.get_active_sessions()
|
||||
@@ -152,9 +157,10 @@ class FeishuLongConnService:
|
||||
if not session_id:
|
||||
session_id = chat_manager.create_session(
|
||||
user_id=session_user_id,
|
||||
work_order_id=None
|
||||
work_order_id=None,
|
||||
tenant_id=tenant_id
|
||||
)
|
||||
logger.info(f"🆕 创建新会话: {session_id}")
|
||||
logger.info(f"🆕 创建新会话: {session_id} (租户: {tenant_id})")
|
||||
|
||||
# 调用实时对话接口处理消息
|
||||
logger.info(f"🤖 调用 TSP Assistant 处理消息...")
|
||||
|
||||
Reference in New Issue
Block a user