diff --git a/app/endpoints/add_contacts_endpoint.py b/app/endpoints/add_contacts_endpoint.py new file mode 100644 index 0000000..6ff7adb --- /dev/null +++ b/app/endpoints/add_contacts_endpoint.py @@ -0,0 +1,33 @@ + +from fastapi import APIRouter,Request,FastAPI +from pydantic import BaseModel +from fastapi import APIRouter, Depends +from pydantic import BaseModel, ValidationError +from common.log import logger + +add_contacts_group_history_router = APIRouter(prefix="/api/addcontactsfromchatroomhistory") + + +class ClearAddContactsGroupHistoryRequest(BaseModel): + wxid: str + chatroomId:str + + +@add_contacts_group_history_router.post("/clear",response_model=None) +async def add_contacts_group_history_clear(request: Request, body: ClearAddContactsGroupHistoryRequest, ): + wxid = body.wxid + chatroom_id=body.chatroomId + + if not wxid: + return {"code": 400, "message": "wxid 不能为空"} + + k,loginfo=await request.app.state.gewe_service.get_login_info_by_wxid_async(wxid) + + if not k: + return {"code":404,"message":f"{wxid} 没有对应的登录信息"} + + await request.app.state.gewe_service.delete_group_add_contacts_history_async(wxid,chatroom_id) + logger.info(f"删除群聊添加好友历史 wxid:{wxid} chatroomId:{chatroom_id}") + return {"message": "操作成功"} + + diff --git a/app/main.py b/app/main.py index 6102429..78d8d9f 100644 --- a/app/main.py +++ b/app/main.py @@ -22,6 +22,7 @@ from app.endpoints.sns_endpoint import sns_router from app.endpoints.agent_endpoint import agent_router from app.endpoints.pipeline_endpoint import messages_router from app.endpoints.label_endpoint import label_router +from app.endpoints.add_contacts_endpoint import add_contacts_group_history_router from tasks import background_worker_task @@ -241,6 +242,7 @@ app.include_router(sns_router) app.include_router(agent_router) app.include_router(messages_router) app.include_router(label_router) +app.include_router(add_contacts_group_history_router) @app.get("/") async def root(): diff --git a/services/gewe_service.py b/services/gewe_service.py index 004944c..e669c6b 100644 --- a/services/gewe_service.py +++ b/services/gewe_service.py @@ -1424,6 +1424,10 @@ class GeWeService: return 1 return 2 + async def delete_group_add_contacts_history_async(self,wxid,chatroom_id)->dict: + hash_key = f"__AI_OPS_WX__:GROUPS_ADD_CONTACT_HISTORY:{wxid}:{chatroom_id}" + await self.redis_service.delete_hash(hash_key) + # 依赖项:获取 GeWeChatCom 单例 async def get_gewe_service(app: FastAPI = Depends()) -> GeWeService: return app.state.gewe_service \ No newline at end of file