feat: 支持企业微信智能机器人 API 模式 - #4100
Conversation
🤖 Augment PR Summary概要:本 PR 为企业微信智能机器人的新版 API 模式增加回调加解密与回复支持。
🤖 Was this summary useful? React with 👍 or 👎 |
There was a problem hiding this comment.
Pull request overview
本 PR 面向 weixin-java-cp 的企业微信智能机器人“新版 API 模式”接入:补齐加密 JSON 回调解密解析能力,并支持使用回调中的 response_url 进行不带 access_token 的加密回复,同时更新文档以区分旧版 access-token 接口链路与新版 API 模式链路。
Changes:
- 新增
WxCpIntelligentRobotCryptUtil:基于现有WxCryptUtil封装机器人 API 模式 JSON 信封的加解密、签名与 URL 校验解密。 - 扩展
WxCpIntelligentRobotService/WxCpIntelligentRobotServiceImpl:新增解密回调解析parseEncryptedCallbackMessage(...)与response_url加密回复replyMessage(...)(走postWithoutToken)。 - 新增针对加解密封装、回调解密解析、response_url 无 token 回复的 TestNG 用例,并更新
INTELLIGENT_ROBOT.md文档示例。
验证(基于 PR 描述)
- 已编译新增生产与测试代码;TestNG 3 项测试通过。
剩余风险 / 需要关注点
WxCpIntelligentRobotService作为 public 接口新增非 default 方法,存在对下游自定义实现/Mock 的源码与二进制兼容性风险(见已留评审意见)。
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/crypto/WxCpIntelligentRobotCryptUtil.java | 新增机器人 API 模式 JSON 信封加解密工具(签名、encrypt/decrypt/verifyUrl)。 |
| weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpIntelligentRobotService.java | 新增 API 模式回调解密解析与 response_url 加密回复接口方法。 |
| weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpIntelligentRobotServiceImpl.java | 实现新增的 API 模式能力,并通过 postWithoutToken 走无 token 通道。 |
| weixin-java-cp/src/test/java/me/chanjar/weixin/cp/util/crypto/WxCpIntelligentRobotCryptUtilTest.java | 覆盖加密信封可解密回原文的回归单测。 |
| weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpIntelligentRobotApiModeServiceTest.java | 覆盖加密回调解析与 response_url 加密回复(mock postWithoutToken)的单测。 |
| weixin-java-cp/INTELLIGENT_ROBOT.md | 更新接入文档:区分旧 access-token 与新版 API 模式链路与示例。 |
| docs/superpowers/specs/2026-08-21-cp-intelligent-robot-api-mode-design.md | 增加设计说明,明确范围、接口与验证点。 |
| docs/superpowers/plans/2026-08-21-cp-intelligent-robot-api-mode.md | 增加实施计划文档(当前存在测试框架/测试类名与实际不一致点)。 |
Suppressed comments (4)
docs/superpowers/plans/2026-08-21-cp-intelligent-robot-api-mode.md:55
- Task 2 的测试文件路径/类名与本 PR 实际新增的 API-mode 测试不一致:本次新增的是 WxCpIntelligentRobotApiModeServiceTest,而不是把用例放到 WxCpIntelligentRobotServiceImplTest。建议同步更新该计划文档中的测试文件指向,方便按文档执行验证。
**Files:**
- Modify: `weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpIntelligentRobotService.java`
- Modify: `weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpIntelligentRobotServiceImpl.java`
- Test: `weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpIntelligentRobotServiceImplTest.java`
docs/superpowers/plans/2026-08-21-cp-intelligent-robot-api-mode.md:70
- 计划文档中运行单测的命令使用了
-Dtest=WxCpIntelligentRobotServiceImplTest,但 API 模式新增用例在WxCpIntelligentRobotApiModeServiceTest;按当前文档执行会漏跑关键用例。建议改为运行新增的测试类。
Run: `mvn -pl weixin-java-cp -Dtest=WxCpIntelligentRobotServiceImplTest test`
Expected: compilation failure because new service methods do not exist.
docs/superpowers/plans/2026-08-21-cp-intelligent-robot-api-mode.md:79
- 同上,Step 4 的 PASS 命令也应运行本次新增的
WxCpIntelligentRobotApiModeServiceTest,否则无法验证加密回调解析与 response_url 回复链路。
Run: `mvn -pl weixin-java-cp -Dtest=WxCpIntelligentRobotServiceImplTest test`
Expected: PASS.
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpIntelligentRobotService.java:115
- 同上,
replyMessage作为新增的非 default 接口方法也会带来实现类二进制不兼容风险。建议改为default方法(默认抛 UnsupportedOperationException),由WxCpIntelligentRobotServiceImpl提供实际实现。
String replyMessage(String responseUrl, String plainJson, String token, String encodingAesKey, String aiBotId,
String timestamp, String nonce) throws WxErrorException;
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ae7b04e7dd
ℹ️ 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".
关联
Fixes #4099
变更
WxCpIntelligentRobotMessage。response_url加密回复,且明确使用无access_token的请求通道。验证