fix wechat mp session rotation and bootstrap reuse

This commit is contained in:
john
2026-07-04 12:10:22 +08:00
parent 3139395b58
commit bef72b2768
3 changed files with 352 additions and 46 deletions
+16
View File
@@ -2259,6 +2259,21 @@ export function createUserAuth(pool, options = {}) {
);
};
const countWechatAgentSessionMessages = async ({
appId,
openid,
agentSessionId,
}) => {
if (!appId || !openid || !agentSessionId) return 0;
const [rows] = await pool.query(
`SELECT COUNT(*) AS count
FROM h5_wechat_mp_messages
WHERE app_id = ? AND openid = ? AND agent_session_id = ?`,
[appId, openid, agentSessionId],
);
return Number(rows?.[0]?.count ?? 0);
};
const recordWechatMpMessage = async ({
appId,
openid,
@@ -2845,6 +2860,7 @@ export function createUserAuth(pool, options = {}) {
upsertWechatAgentRoute,
clearWechatAgentRoute,
touchWechatAgentRoute,
countWechatAgentSessionMessages,
recordWechatMpMessage,
finishWechatMpMessage,
insertWechatMpMessageDetail,