Skip to content

fix(dingtalk): handle richText and replied media attachments - #1649

Open
wgqi1126 wants to merge 4 commits into
chenhg5:mainfrom
wgqi1126:fix/dingtalk-richtext-images
Open

fix(dingtalk): handle richText and replied media attachments#1649
wgqi1126 wants to merge 4 commits into
chenhg5:mainfrom
wgqi1126:fix/dingtalk-richtext-images

Conversation

@wgqi1126

@wgqi1126 wgqi1126 commented Aug 6, 2026

Copy link
Copy Markdown

Summary

  • parse both text and embedded image download codes from DingTalk richText callbacks
  • prefer the working downloadCode field and retain pictureDownloadCode as a compatibility fallback
  • download multiple embedded pictures and pass them with text in the same core.Message
  • recover media metadata from text.repliedMsg.content when users reply to a group file or picture and @mention the robot
  • route quoted picture / image messages to Images and quoted files to Files; use MIME detection as a fallback for new downloadable reply types
  • keep usable text and successfully downloaded attachments when one media download fails
  • reuse bounded download helpers: 25 MiB for images and 50 MiB for files

Problem

DingTalk group media reaches Stream robots in more than one callback shape:

  1. An @mention mixed with text and pictures arrives as msgtype=richText, with image download codes inside content.richText[].
  2. A user can first send a file or picture, then reply to it and @mention the robot. DingTalk sends this as top-level msgtype=text; the referenced media is nested under text.repliedMsg with msgType and content.downloadCode.

The adapter previously handled the outer text but silently dropped media in both shapes. It also selected pictureDownloadCode when both rich-text code fields were present, while the real download API requires downloadCode for these callbacks.

Behavior

  • rich-text text and pictures are delivered together
  • reply-to-file messages preserve the user text and add a named FileAttachment
  • reply-to-picture messages preserve the user text and add an ImageAttachment
  • unknown replied message types that expose a download code are downloaded as bounded attachments and promoted to images when their MIME type starts with image/
  • download failures are logged without dropping the remaining text or other usable pictures

Tests

  • go test ./platform/dingtalk -count=1
  • go test -race ./platform/dingtalk -count=1
  • go vet ./platform/dingtalk
  • go build ./cmd/cc-connect

Regression coverage includes mixed rich text, multiple pictures with partial download failure, download-code precedence, reply-to-file, reply-to-picture, standalone picture aliases, file names, MIME types, and attachment bytes.

@wgqi1126
wgqi1126 requested a review from chenhg5 as a code owner August 6, 2026 09:09
@wgqi1126 wgqi1126 changed the title fix(dingtalk): handle embedded images in richText messages fix(dingtalk): handle richText and replied media attachments Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant