From 9928acacb248dad7d3ba9a7f3340234bf9e4cd3c Mon Sep 17 00:00:00 2001 From: liufumingren Date: Mon, 12 Oct 2026 20:11:07 +0800 Subject: [PATCH] =?UTF-8?q?fix(wechat):=20QUERY=5FAUTH=5FCODE=20=E5=93=8D?= =?UTF-8?q?=E5=BA=94=E4=BD=93=E6=94=B9=E5=9B=9E=E7=A9=BA=E4=B8=B2=EF=BC=88?= =?UTF-8?q?=E4=B8=8D=E8=A2=AB=E5=8A=A8=E5=9B=9E=E5=A4=8D=EF=BC=89=EF=BC=8C?= =?UTF-8?q?=E5=AE=A2=E6=9C=8D=E6=B6=88=E6=81=AF=E4=BF=9D=E6=8C=81=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E5=BC=82=E6=AD=A5=E5=8F=8C=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/wechatOpen.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controller/wechatOpen.js b/app/controller/wechatOpen.js index 8e39fff..312fd0f 100644 --- a/app/controller/wechatOpen.js +++ b/app/controller/wechatOpen.js @@ -576,16 +576,13 @@ class WechatOpenController extends Controller { ctx.logger.warn(`[wechatOpen.events] 命中官方检测步骤2-公众号被动回复 appid=${appid} type=${detectAccountType(appid)}`); } else if (content.includes('QUERY_AUTH_CODE')) { // 微信全网发布检测场景(官方步骤3=公众号客服/步骤4=小程序客服):文本携带授权码 - // (QUERY_AUTH_CODE:)。双通道兜底: - // 1) 被动回复 _from_api(步骤4 文档未规定响应体,被动回复能让模拟粉丝直接收到消息); - // 2) 后台异步发送客服消息(含前缀/去前缀双发,官方要求走客服消息接口)。 + // (QUERY_AUTH_CODE:)。处理:响应体直接回空串(官方要求「5 秒内返回空串 + // 表明暂时不回复」),客服消息由后台异步发送(含前缀/去前缀双发)。 const authCode = content.replace('QUERY_AUTH_CODE:', '').trim(); const accountType = detectAccountType(appid); ctx.logger.warn(`[wechatOpen.events] 命中官方检测步骤3/4-客服消息回复 appid=${appid} type=${accountType} code=${authCode}`); - // 被动回复内容(官方文档字面口径:QUERY_AUTH_CODE: 后的实际值 + _from_api) - replyContent = `${authCode}_from_api`; - + // 官方要求:不被动回复,响应体回空串;客服消息流程放入后台异步执行 ctx.runInBackground(async () => { const client = new WechatOpenClient(ctx); let refreshToken = null; @@ -646,6 +643,9 @@ class WechatOpenController extends Controller { ctx.logger.error(`[wechatOpen.events] 客服消息发送异常: ${e.message}`); } }); + + // 响应体回空串(不被动回复,与 PHP 参考实现一致) + return EMPTY_REPLY; } else { replyContent = `收到您的消息:${content}\n我会尽快回复您!`; }