Skip to content

feat: 完成 P6 通知渠道收口 - #1275

Merged
ZhuLinsen merged 1 commit into
ZhuLinsen:mainfrom
massif-01:feat/1200-p6-gotify-and-evaluations
May 13, 2026
Merged

feat: 完成 P6 通知渠道收口#1275
ZhuLinsen merged 1 commit into
ZhuLinsen:mainfrom
massif-01:feat/1200-p6-gotify-and-evaluations

Conversation

@massif-01

@massif-01 massif-01 commented May 13, 2026

Copy link
Copy Markdown
Collaborator

PR Type

  • fix
  • feat
  • refactor
  • docs
  • chore
  • test

Background And Problem

Issue #1200 的 P6-A ntfy 已合并,本 PR 收口剩余 P6-B/C/D,避免把通知矩阵、文档、changelog 和 Web 配置元数据拆成多个互相冲突的小 PR。

本 PR 不关闭 #1200,只作为剩余 P6 工作的合并收口。

Why Combined

本 PR 有意将 P6-B / P6-C / P6-D 合并为一个 draft PR,而不是拆成三个独立 PR。原因是三段工作共享同一组通知矩阵、.env.example、Web 配置 schema/help、workflow env、专题文档和 docs/CHANGELOG.md;拆开提交会让这些文件反复产生重叠修改和 merge conflict,review 时也更难判断最终通知能力矩阵是否一致。

范围上仍按 P6-B/C/D 分段隔离:P6-B 是现有渠道校验和文档收口,P6-C 是 Gotify runtime,P6-D 仅是 WebPush / Apprise docs-only 评估;本 PR 不把 WebPush / Apprise 或 Bark 混入运行时实现。

Scope Of Change

P6-B:

  • 收紧 ntfy 结构化校验,修复 https://ntfy.sh/%20 这类 URL 编码空白 topic 被误判为有效 topic endpoint 的问题。
  • Bark 保持 custom webhook 基线,只补充 Web help、配置示例和文档说明,不新增 BARK_* 或一等渠道。
  • AstrBot 做覆盖审计后不引入 runtime 改动。

P6-C:

  • 新增 Gotify 一等通知渠道,支持 GOTIFY_URL / GOTIFY_TOKEN
  • GOTIFY_URL 是 Gotify server base URL,可包含反向代理 path prefix,但不包含 /message;sender 内部拼接 /message
  • Gotify token 通过 X-Gotify-Key header 发送,不放入 URL;payload 使用 JSON 并声明 Markdown display extras。
  • 接入普通通知、聚合报告、路由 allowlist、diagnostics、setup status、Web/API notification test、workflow env、配置 registry 和前端 channel union。

P6-D:

  • docs/notifications.md 增加 WebPush / Apprise docs-only 评估。
  • 不新增 WebPush / Apprise 运行时依赖、配置入口或发送路径。

同步更新:.env.exampledocs/notifications.mddocs/full-guide.mddocs/full-guide_EN.mddocs/CHANGELOG.md、Web 设置 help 与测试。

Issue Link

Refs #1200

Verification Commands And Results

git diff --check

结果:通过,无 whitespace error。

bash -n /private/tmp/dsa_daily_analysis_run.sh

结果:通过。该脚本由 .github/workflows/daily_analysis.yml执行股票分析 step run: 内容提取生成,用于校验 workflow shell 片段语法。

python -m pytest tests/test_config_validate_structured.py tests/test_notification_sender.py tests/test_notification.py tests/test_notification_routing.py tests/test_pipeline_notification_image_routing.py tests/test_notification_diagnostics.py tests/test_system_config_service.py tests/test_system_config_api.py tests/test_daily_analysis_workflow_notification_env.py tests/test_config_registry.py

结果:373 passed, 35 warnings, 43 subtests passed

cd apps/dsa-web && npm run test -- NotificationTestPanel
cd apps/dsa-web && npm run lint
cd apps/dsa-web && npm run build

结果:测试 1 passed / 3 tests passed,lint 通过,build 通过;Vite 仍提示现有大 chunk warning。

PATH=.venv/bin:$PATH ./scripts/ci_gate.sh

结果:1924 passed, 2 deselected, 42 warnings, 166 subtests passedbackend-gate: all checks passed

Compatibility And Risk

  • 兼容性:未改变既有渠道默认行为;Gotify 默认未配置不启用;ntfy 只收紧 URL 编码空白 topic 的结构化校验。
  • 范围说明:本 PR 合并了原计划中可拆分的 P6-B/C/D,是为了减少文档、changelog、通知矩阵和 Web 配置元数据的重复冲突。
  • 明确不做:不新增 WebPush / Apprise runtime,不引入 Apprise 依赖,不注册 WebPush Service Worker,不把 Bark 升级为一等渠道,不新增 BARK_* 配置。
  • Gotify API 依据:官方 Push messages 使用 /message 推送;REST API 支持通过 X-Gotify-Key header 传 token;Message Extras 支持 client::display.contentType=text/markdown
  • 外部真实 Gotify smoke 未执行:本 PR 使用 mocked HTTP 单元测试覆盖 endpoint、header auth、payload、timeout、失败隔离和脱敏;真实端点验证可在获得一次性 Gotify endpoint 后补充。

Rollback Plan

Revert this PR 即可回滚 Gotify 渠道、ntfy 校验收紧、Bark 文档补充和 WebPush / Apprise 评估文档;无需数据迁移。若已配置 GOTIFY_URL / GOTIFY_TOKEN,回滚后这些 env 会被旧版本忽略。

EXTRACT_PROMPT Change (if applicable)

未修改 src/services/image_stock_extractor.pyEXTRACT_PROMPT

展开 / Expand: Full EXTRACT_PROMPT
N/A

Checklist

  • 本 PR 有明确动机和业务价值 / This PR has a clear motivation and value
  • 已提供可复现的验证命令与结果 / Reproducible verification commands and results are included
  • 已评估兼容性与风险 / Compatibility and risk have been assessed
  • 已提供回滚方案 / A rollback plan is provided
  • 若涉及用户可见变更,已同步更新相关文档与 docs/CHANGELOG.mdREADME.md 仅在首页级信息变化时更新,细节优先写入 docs/*.md / If user-visible changes are included, relevant docs and docs/CHANGELOG.md are updated; README.md is updated only for homepage-level changes, with details kept in docs/*.md

@github-actions

Copy link
Copy Markdown

🤖 自动审查报告

项目 结果
📊 变更文件 29 个
➕ 新增行数 833 行
➖ 删除行数 34 行
🔍 静态检查 ✅ 通过
🧠 AI 审查 ✅ 已完成

📁 修改的文件

  • 📝 .env.example (+6/-1)
  • 📝 .github/workflows/daily_analysis.yml (+5/-0)
  • 📝 api/v1/schemas/system_config.py (+1/-0)
  • 📝 apps/dsa-web/src/components/settings/NotificationTestPanel.tsx (+1/-0)
  • 📝 apps/dsa-web/src/components/settings/__tests__/NotificationTestPanel.test.tsx (+1/-0)
  • 📝 apps/dsa-web/src/locales/settingsHelp.ts (+34/-0)
  • 📝 apps/dsa-web/src/types/systemConfig.ts (+1/-0)
  • 📝 apps/dsa-web/src/utils/systemConfigI18n.ts (+10/-0)
  • 📝 docs/CHANGELOG.md (+3/-0)
  • 📝 docs/full-guide.md (+32/-2)
  • 📝 docs/full-guide_EN.md (+45/-3)
  • 📝 docs/notifications.md (+48/-6)
  • 📝 src/config.py (+45/-2)
  • 📝 src/core/config_registry.py (+38/-1)
  • 📝 src/core/pipeline.py (+6/-1)
  • 📝 src/notification.py (+13/-1)
  • 📝 src/notification_routing.py (+1/-0)
  • 📝 src/notification_sender/__init__.py (+1/-0)
  • 🆕 src/notification_sender/gotify_sender.py (+121/-0)
  • 📝 src/services/notification_diagnostics.py (+33/-1)

... 还有 9 个文件


🧠 AI 代码审查意见

结论

Ready to Merge

结构化审查结果

  • 必要性:通过。
    本 PR 旨在整合 [Feature] DSA 后续开发规划:[通知渠道网关] 渠道基线、测试、Body 模板、路由、降噪与长尾渠道扩展 #1200 中剩余的 P6-B/C/D 通知渠道相关工作,避免将通知矩阵、文档、changelog 和 Web 配置元数据拆分成多个可能互相冲突的小 PR,具有明确的业务价值和操作效率考量。主要内容包括新增 Gotify 一等通知渠道、收紧 ntfy 结构化校验、以及补充 Bark 和 WebPush/Apprise 的文档评估。

  • 关联性:通过。
    PR 描述明确指出 "Refs [Feature] DSA 后续开发规划:[通知渠道网关] 渠道基线、测试、Body 模板、路由、降噪与长尾渠道扩展 #1200",与现有 Issue 建立了关联。

  • 类型:建议类型匹配。
    PR 类型标记为 feat (新增 Gotify 渠道、ntfy 校验收紧)、docs (文档、Web UI help、CHANGELOG 更新) 和 test (新增与更新测试),与 PR 实际内容高度吻合。

  • 描述完整性:完整。
    PR 描述包含了背景、变更范围、详细的验证命令与结果、兼容性与风险评估、回滚方案,并勾选了所有 Checklist 项。

    • 验证命令与结果非常全面,覆盖了 git diff --checkdaily_analysis_run.sh (workflow 语法)、pytest (后端单元/集成测试)、npm run test/lint/build (前端测试),以及关键的后端 CI 门禁脚本 ./scripts/ci_gate.sh,并且所有结果均为通过。
    • CI 检查状态显示 py_compileflake8 均已通过。
    • 兼容性与风险评估清晰,明确了变更范围、不新增运行时依赖的渠道,并注明了 Gotify API 依据和外部真实 Gotify smoke 测试未执行但有 mocked HTTP 单元测试覆盖的情况。
    • 回滚方案清晰且易于执行。
  • 风险级别:低。

    • Gotify 作为新增的一等通知渠道,默认未配置时不启用,对现有系统行为无影响。
    • ntfy 校验收紧是一个修复性改进,仅收紧了对 URL 编码空白 topic 的误判,提高了数据质量,不会影响已正确配置的合法 ntfy 端点。
    • Bark、WebPush 和 Apprise 的变更仅限于文档层面,不引入新的运行时依赖或配置。
    • PR 提供了全面的测试覆盖和详尽的验证结果,降低了引入新问题的风险。

必改项

无。基于当前可见的 diff、详细的 PR 描述和全面的验证结果,未发现阻碍 PR 合并的正确性、安全性、CI 不通过或描述与实际改动存在实质性矛盾的问题。

建议项

  1. 代码可见性:鉴于 diff 长度截断,部分核心 Python 文件如 src/notification_sender/gotify_sender.py 的具体实现细节未能完全展示。在未来涉及新增复杂功能或大量核心逻辑变更的 PR 中,如果 diff 仍然过长,可以考虑在 PR 描述中补充核心实现文件的主要逻辑概述或关键代码片段,以辅助审查者更全面地了解具体实现方式。本次 PR 由于验证充分且风险较低,不构成阻碍。

💡 提示: 请确保代码已通过本地测试,并遵循项目代码规范。

@ZhuLinsen ZhuLinsen left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

评审结论

  • 必要性:通过,P6 通知渠道收口与 #1200 剩余工作相关,新增 Gotify 一等渠道并同步配置、文档、Web 与测试矩阵有明确价值。
  • 是否有对应 issue:有,Refs #1200
  • PR 类型:feat,主改动是新增 Gotify 通知渠道;同时包含 ntfy 校验修复、文档与测试补充。
  • description 完整性:完整,已说明范围、兼容性、外部 Gotify API 依据、验证结果、未做真实 Gotify smoke 的原因与回滚方案,符合 AGENTS.md 对用户可见能力、配置与文档同步的要求。
  • 是否可直接合入:可,当前 CI 为 success,改动覆盖 .env.example、专题文档、双语文档、CHANGELOG、Web 配置元数据与后端测试;mergeable_state=blocked 更像分支保护状态,不构成本次代码审查阻断点。

🤖 此回复由 OpenReview Bot 自动生成,仅供参考。如有疑问请 @维护者。

@massif-01

Copy link
Copy Markdown
Collaborator Author

@codex review

@ZhuLinsen ZhuLinsen left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

跟进结论

  • 结论:接受 + 最新 head 复核后,Gotify 运行时接入、Web/API、路由、诊断、Actions env、文档和测试矩阵基本一致,维持可合入判断。
  • 是否仍有阻断:无 + 当前 CI 全部成功;mergeable_state=blocked 不单独构成代码审查阻断。

说明

  1. src/notification_sender/gotify_sender.pyGOTIFY_URL 作为 base URL 拼接 /message、token 走 X-Gotify-Key、payload 使用 JSON 和 Markdown extras;与 Gotify 官方 push/message extras/API 说明一致(https://gotify.net/docs/pushmsg、https://gotify.net/docs/msgextras、https://pkg.go.dev/github.com/gotify/server/v2/docs)。
  2. src/services/system_config_service.py / tests/test_system_config_service.py:Web 测试不会持久化临时 Gotify 配置,masked secret 不会覆盖已有值;结构化事实里的“运行时模型清理”提示不落在本次新增 Gotify 通知字段上,未看到静默清空用户通知配置的问题。
  3. .env.exampledocs/notifications.mddocs/full-guide.mddocs/full-guide_EN.mddocs/CHANGELOG.md 已同步 Gotify、ntfy 收紧、Bark custom webhook 和 WebPush/Apprise docs-only 范围;README 未改符合仓库规则。
  4. 未执行真实 Gotify endpoint smoke 仍是剩余风险,但 PR 已明确说明,并已有 mock 测试覆盖 endpoint、header auth、payload、timeout、失败隔离和脱敏;不作为阻断。

🤖 此回复由 OpenReview Bot 自动生成,仅供参考。如有疑问请 @维护者。

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ZhuLinsen
ZhuLinsen merged commit a75a0c5 into ZhuLinsen:main May 13, 2026
10 checks passed
davidzhengdai pushed a commit to davidzhengdai/daily_stock_analysis that referenced this pull request May 13, 2026
Anyone878 pushed a commit to Anyone878/daily_stock_analysis that referenced this pull request May 17, 2026
MY903 pushed a commit to MY903/daily_stock_analysis that referenced this pull request Jun 15, 2026
EchoingFootsteps pushed a commit to EchoingFootsteps/daily_stock_analysis that referenced this pull request Jul 4, 2026
bmwu pushed a commit to bmwu/daily_stock_analysis that referenced this pull request Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants