fix(wechat): 检测客服回复双发(含 queryauthcode@@@ 前缀与去前缀两个版本),兼容检测脚本对回复内容的两种核对口径
This commit is contained in:
parent
2c0ae6e089
commit
2f842c1a4b
@ -629,8 +629,19 @@ class WechatOpenController extends Controller {
|
||||
}
|
||||
|
||||
ctx.logger.warn(`[wechatOpen.events] 客服回复令牌来源 source=${tokenSource || 'none'} appid=${appid} has_token=${!!refreshToken}`);
|
||||
|
||||
// 回复内容双发兼容:官方检测文本 QUERY_AUTH_CODE:queryauthcode@@@<code>,
|
||||
// 官方文档字面要求回复 <queryauthcode@@@code>_from_api;但检测脚本可能按
|
||||
// 「去掉 queryauthcode@@@ 标记前缀的真实 code」核对,两条都发确保命中。
|
||||
const codeValue = authCode.trim();
|
||||
const pureCode = codeValue.startsWith('queryauthcode@@@')
|
||||
? codeValue.slice('queryauthcode@@@'.length)
|
||||
: codeValue;
|
||||
try {
|
||||
await this.sendMessage(appid, openid, `${authCode}_from_api`, refreshToken);
|
||||
await this.sendMessage(appid, openid, `${codeValue}_from_api`, refreshToken);
|
||||
if (pureCode && pureCode !== codeValue) {
|
||||
await this.sendMessage(appid, openid, `${pureCode}_from_api`, refreshToken);
|
||||
}
|
||||
} catch (e) {
|
||||
ctx.logger.error(`[wechatOpen.events] 客服消息发送异常: ${e.message}`);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user