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 # 判断是否转人工处理功能