feat: download and decrypt inbound WeChat CDN images#17
Open
yuxianzhao0921-del wants to merge 1 commit into
Open
feat: download and decrypt inbound WeChat CDN images#17yuxianzhao0921-del wants to merge 1 commit into
yuxianzhao0921-del wants to merge 1 commit into
Conversation
Upstream had AES-128-ECB helpers and a downloadAndDecryptMedia function but never wired them into the polling loop for inbound images. This commit closes that gap: - Fix parseAesKey: WeChat's media.aes_key is base64 of a hex string (32 UTF-8 chars → 16 key bytes), not raw base64 of 16 bytes - Expand ImageItem with aeskey (hex) and media.full_url fields to match actual inbound message structure - Add downloadAndSaveImage: download → decrypt → detect format via magic bytes → save to ~/.claude/channels/wechat/images/ - Wire into polling loop: image messages now deliver a file path instead of just "[图片]" Tested with real WeChat CDN images (AES-128-ECB encrypted JPEG). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Upstream had AES-128-ECB helpers and a
downloadAndDecryptMediafunction but never wired them into the polling loop for inbound images. This PR closes that gap.What's included
parseAesKey: WeChat's inboundmedia.aes_keyis base64-encoded hex string (32 UTF-8 chars → 16 key bytes), not raw base64 of 16 bytes. The new parser handles both formats gracefully.downloadAndSaveImage: download → decrypt → detect format via magic bytes (JPEG/PNG/GIF/WebP) → save to~/.claude/channels/wechat/images/ImageIteminterface: addedaeskey(hex),media.full_url, andCDNMediatype to match actual inbound message structure[图片: /path/to/file.jpg]) instead of just[图片]How it works
Relation to PR #10
This overlaps partially with #10. Key differences:
cdn_url/media.full_urldirectly; feat: receive media messages (image, video, voice, file) #10 usesencrypt_query_param+ CDN base URLBoth approaches work. Happy to collaborate on merging the best parts if needed.
Test plan
Readtool🤖 Generated with Claude Code