fix(dingtalk): parse rich text image messages

This commit is contained in:
姚章浩
2026-07-16 00:49:26 +08:00
parent c9c4f0aaa5
commit 7ccf3365f0
4 changed files with 119 additions and 14 deletions
+22
View File
@@ -41,6 +41,28 @@ func TestParseCallbackMessagePicture(t *testing.T) {
}
}
func TestParseCallbackMessageRichTextWithPictureAndText(t *testing.T) {
msg := &callbackMessage{
MsgID: "msg-richtext-1",
Msgtype: "richText",
Content: []byte(`{"richText":[{"text":" 请描述这张图片 "},{"type":"picture","downloadCode":"rich-webhook-code"}]}`),
}
got := parseCallbackMessage(msg)
if got.MessageType != im.MessageTypeImage {
t.Fatalf("MessageType = %q, want image", got.MessageType)
}
if got.Content != "请描述这张图片" {
t.Fatalf("Content = %q", got.Content)
}
if got.FileKey != "rich-webhook-code" {
t.Fatalf("FileKey = %q", got.FileKey)
}
if got.FileName != "msg-richtext-1.png" {
t.Fatalf("FileName = %q", got.FileName)
}
}
func TestAdapterDownloadFileUsesMessageFilesAPI(t *testing.T) {
var sawToken bool
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {