fix wechat bug
This commit is contained in:
parent
4f89780a0f
commit
a4df2f5213
@ -36,13 +36,11 @@ async def user_message(background_tasks: BackgroundTasks, request: Request):
|
|||||||
return schemas.Response(success=True)
|
return schemas.Response(success=True)
|
||||||
|
|
||||||
|
|
||||||
@router.get("/", summary="微信验证")
|
|
||||||
def wechat_verify(echostr: str, msg_signature: str,
|
def wechat_verify(echostr: str, msg_signature: str,
|
||||||
timestamp: Union[str, int], nonce: str) -> Any:
|
timestamp: Union[str, int], nonce: str) -> Any:
|
||||||
"""
|
"""
|
||||||
微信验证响应
|
微信验证响应
|
||||||
"""
|
"""
|
||||||
logger.info(f"收到微信验证请求: {echostr}")
|
|
||||||
try:
|
try:
|
||||||
wxcpt = WXBizMsgCrypt(sToken=settings.WECHAT_TOKEN,
|
wxcpt = WXBizMsgCrypt(sToken=settings.WECHAT_TOKEN,
|
||||||
sEncodingAESKey=settings.WECHAT_ENCODING_AESKEY,
|
sEncodingAESKey=settings.WECHAT_ENCODING_AESKEY,
|
||||||
@ -60,12 +58,26 @@ def wechat_verify(echostr: str, msg_signature: str,
|
|||||||
return PlainTextResponse(sEchoStr)
|
return PlainTextResponse(sEchoStr)
|
||||||
|
|
||||||
|
|
||||||
@router.get("/", summary="VoceChat验证")
|
def vocechat_verify(token: str) -> Any:
|
||||||
def vocechat_verify() -> Any:
|
|
||||||
"""
|
"""
|
||||||
VoceChat验证响应
|
VoceChat验证响应
|
||||||
"""
|
"""
|
||||||
return {"status": "OK"}
|
if token == settings.API_TOKEN:
|
||||||
|
return {"status": "OK"}
|
||||||
|
return {"status": "ERROR"}
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/", summary="回调请求验证")
|
||||||
|
def incoming_verify(token: str = None, echostr: str = None, msg_signature: str = None,
|
||||||
|
timestamp: Union[str, int] = None, nonce: str = None) -> Any:
|
||||||
|
"""
|
||||||
|
微信/VoceChat等验证响应
|
||||||
|
"""
|
||||||
|
logger.info(f"收到验证请求: token={token}, echostr={echostr}, "
|
||||||
|
f"msg_signature={msg_signature}, timestamp={timestamp}, nonce={nonce}")
|
||||||
|
if echostr and msg_signature and timestamp and nonce:
|
||||||
|
return wechat_verify(echostr, msg_signature, timestamp, nonce)
|
||||||
|
return vocechat_verify(token)
|
||||||
|
|
||||||
|
|
||||||
@router.get("/switchs", summary="查询通知消息渠道开关", response_model=List[NotificationSwitch])
|
@router.get("/switchs", summary="查询通知消息渠道开关", response_model=List[NotificationSwitch])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user