From 7fa1859c0ceaad459231b35828a5973069f86b98 Mon Sep 17 00:00:00 2001 From: H Vs Date: Wed, 30 Apr 2025 17:22:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E5=AD=97=E5=9B=9E=E5=A4=8D=E7=99=BD?= =?UTF-8?q?=E5=90=8D=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/endpoints/config_endpoint.py | 2 ++ app/endpoints/pipeline_endpoint.py | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/endpoints/config_endpoint.py b/app/endpoints/config_endpoint.py index 4d8c033..49e8487 100644 --- a/app/endpoints/config_endpoint.py +++ b/app/endpoints/config_endpoint.py @@ -27,6 +27,7 @@ class SaveConfigRequest(BaseModel): @config_router.post("/wxchat/getconfig",response_model=None) #@validate_wxid async def get_config(request: Request, body: GetConfigRequest): + wxid = body.wxid if not wxid: return {"code": 400, "message": "wxid 不能为空"} @@ -80,6 +81,7 @@ async def save_config(request: Request, body: SaveConfigRequest): # 去重 validated_config.chatroomIdWhiteList=list(set(validated_config.chatroomIdWhiteList)) validated_config.addContactsFromChatroomIdWhiteList=list(set(validated_config.addContactsFromChatroomIdWhiteList)) + validated_config.privateChatWhiteList=list(set(validated_config.privateChatWhiteList)) except ValidationError as e: return {'code': 407, 'message': e.errors().__str__()} diff --git a/app/endpoints/pipeline_endpoint.py b/app/endpoints/pipeline_endpoint.py index cb14f70..2395d5c 100644 --- a/app/endpoints/pipeline_endpoint.py +++ b/app/endpoints/pipeline_endpoint.py @@ -374,7 +374,11 @@ async def handle_text_async(request: Request,token_id,app_id, wxid,msg_data,from validated_config = AgentConfig.model_validate(config) if not validated_config.privateGroupChatEnabled: - logger.warning(f"微信号 {wxid} 关闭好友和群自动回复功能,{handle_text_async.__name__} 不回复消息") + logger.warning(f"智能体微信号 {wxid} 关闭好友和群自动回复功能,{handle_text_async.__name__} 不回复消息") + return + + if wxid != from_wxid and from_wxid not in validated_config.privateChatWhiteList: + logger.warning(f"智能体微信号 {wxid} 的好友 {from_wxid} 不在回复白名单,{handle_text_async.__name__} 不回复消息") return # 判断是否转人工处理功能