ソースを参照

清理群加好友历史

1257
H Vs 1週間前
コミット
1accb05c38
3個のファイルの変更39行の追加0行の削除
  1. +33
    -0
      app/endpoints/add_contacts_endpoint.py
  2. +2
    -0
      app/main.py
  3. +4
    -0
      services/gewe_service.py

+ 33
- 0
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": "操作成功"}



+ 2
- 0
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():


+ 4
- 0
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

読み込み中…
キャンセル
保存