This commit is contained in:
yumoqing 2026-03-02 13:53:17 +08:00
parent 67fb74fa26
commit 2745963fbc

View File

@ -180,9 +180,9 @@ class WOAHandler:
"""处理用户消息和事件""" """处理用户消息和事件"""
# 1. 验证签名 # 1. 验证签名
query = request.query query = request.query
signature = query.get('signature', '') signature = query.get('signature', '')
timestamp = query.get('timestamp', '') timestamp = query.get('timestamp', '')
nonce = query.get('nonce', '') nonce = query.get('nonce', '')
is_valid, _ = self._verify_signature(request) is_valid, _ = self._verify_signature(request)
if not is_valid: if not is_valid:
return web.Response(text="failed", status=403) return web.Response(text="failed", status=403)
@ -194,9 +194,9 @@ class WOAHandler:
# decrypt_message 会自动处理解密和 XML 解析,返回 wechatpy 的消息对象 # decrypt_message 会自动处理解密和 XML 解析,返回 wechatpy 的消息对象
# 如果未开启加密,它也会正常解析 XML # 如果未开启加密,它也会正常解析 XML
msg = self.crypto.decrypt_message(body, msg = self.crypto.decrypt_message(body,
signature=signature, signature=signature,
timestamp=timestamp, timestamp=timestamp,
nonce=nonce) nonce=nonce)
except Exception as e: except Exception as e:
error(f"消息解密或解析失败: {e}, {body=}") error(f"消息解密或解析失败: {e}, {body=}")
return web.Response(text="success") # 防止微信重试 return web.Response(text="success") # 防止微信重试