docs(notify): 诊断补第 5b 节,指向平台侧的转发检查

用户实跑结果:sendNotify 加载正常、WEBHOOK 三项前置条件全过、
直打平台两次都 204(含换行/中文/emoji 的完整正文也收下了)。
但 PUSH_PLUS_TOKEN 未设 —— 青龙根本不发 pushplus,所以收到的那条
pushplus 一定来自平台转发,不是脚本自己发的。

补第 5b 节把这条推理写进输出:
- 204 只证明平台收下了,收到 ≠ 转发
- 中间还有两道门:事件要匹配到账号、账号下要有 enabled+active 的
  pushplus 目标
- 给出两个 curl 判据(/api/notify-targets 与 /api/events?category=notify)
  以及 deliveries=N 的读法
- 第 5 节在 PUSH_PLUS_TOKEN 未设时不再只是「跳过」,而是说明
  这条消息必然是平台转发来的
This commit is contained in:
2026-11-05 20:21:02 +08:00
parent 3a711d0a47
commit 3ce29ebee2

View File

@@ -194,7 +194,10 @@ if (!WU) {
hr('5. 直连 pushplus(模板对比)') hr('5. 直连 pushplus(模板对比)')
const PT = process.env.PUSH_PLUS_TOKEN || '' const PT = process.env.PUSH_PLUS_TOKEN || ''
if (!PT) { if (!PT) {
console.log(' · PUSH_PLUS_TOKEN 未设,跳过') console.log(' · PUSH_PLUS_TOKEN 未设 —— 青龙侧不发 pushplus')
console.log(' · 若你收到过 pushplus 消息,那是平台(script-helper)转发来的')
console.log(' → 说明平台侧的通知目标配好了,问题只在「正文被折叠」')
console.log(' → 平台用 template=txt(不折叠),青龙 sendNotify 用 html(折叠)')
} else { } else {
for (const tpl of ['txt', 'html']) { for (const tpl of ['txt', 'html']) {
const content = tpl === 'html' ? DESP.replace(/\n/g, '<br>') : DESP const content = tpl === 'html' ? DESP.replace(/\n/g, '<br>') : DESP
@@ -212,6 +215,28 @@ if (!WU) {
console.log(' · 两条都收不到 → PUSH_PLUS_TOKEN 或实名状态有问题') console.log(' · 两条都收不到 → PUSH_PLUS_TOKEN 或实名状态有问题')
} }
/* ────────── 5b. 平台侧有没有把事件转发出去 ────────── */
hr('5b. 平台侧转发检查')
const base = (() => { try { const u = new URL(finalUrl); return `${u.protocol}//${u.host}` } catch { return '' } })()
console.log(' 平台基址:', base || '(无法从 WEBHOOK_URL 推出)')
console.log('')
console.log(' 第 4 节是 204,说明平台「收下了」。但收到 ≠ 转发,中间还有两道门:')
console.log(' ① 事件要匹配到你的账号(notify_events.user_id 非空,或走 owner 原文透传)')
console.log(' ② 你的账号下要有 enabled=1 且 status=active 的 pushplus 目标')
console.log('')
console.log(' 验证方式(浏览器登录平台后打开开发者工具,或用 curl 带 cookie):')
if (base) {
console.log(` curl -s "${base}/api/notify-targets" -H "cookie: <你的会话 cookie>"`)
console.log(' → items 为空 = 没有目标,平台收到也不会转发(这就是只收到标题的原因)')
console.log(` curl -s "${base}/api/events?category=notify&limit=10" -H "cookie: <你的会话 cookie>"`)
console.log(' → 能看到 action=notify.send 的记录,message 里 deliveries=N')
console.log(' → deliveries=0 表示匹配到了事件但没有任何目标可投')
}
console.log('')
console.log(' 一句话判据:')
console.log(' · 平台 /api/notify-targets 为空 → 去平台「通知」页新建一个 pushplus 目标')
console.log(' · 有目标但 events 里 deliveries=0 → 目标被禁用,或事件没匹配到账号')
/* ────────── 6. 走一遍完整 sendNotify ────────── */ /* ────────── 6. 走一遍完整 sendNotify ────────── */
hr('6. 完整 sendNotify') hr('6. 完整 sendNotify')
if (!sn) { if (!sn) {
@@ -222,6 +247,7 @@ if (!WU) {
console.log('\n 对照第 4 节:') console.log('\n 对照第 4 节:')
console.log(' · 若这里出现「自定义发送通知消息失败」但第 4 节是 204 → 假警报,投递成功') console.log(' · 若这里出现「自定义发送通知消息失败」但第 4 节是 204 → 假警报,投递成功')
console.log(' · 若第 4 节 401/403 → webhook 头或 IP 的问题,与 sendNotify 无关') console.log(' · 若第 4 节 401/403 → webhook 头或 IP 的问题,与 sendNotify 无关')
console.log(' · 已修版本会打「成功🎉 HTTP 204」;仍打失败说明仓库还没更新到这个版本')
} }
hr('完成') hr('完成')
})().catch(e => console.log(' 异常:', e.message)) })().catch(e => console.log(' 异常:', e.message))