feat: request thread roots for chat message list (#635)

Update im +chat-messages-list to request only thread root messages from /open-apis/im/v1/messages by default. This aligns the shortcut request shape with topic-group usage and makes the intended API behavior explicit in both runtime params and dry-run output.

Change-Id: I3901b27e70b0e4db506ff199eb03c96fcf98671d
This commit is contained in:
YangJunzhou-01
2026-04-24 10:40:35 +08:00
committed by GitHub
parent e42033f5b5
commit 6f444c5dc2
4 changed files with 48 additions and 13 deletions

1
.gitignore vendored
View File

@@ -33,6 +33,7 @@ tests/mail/reports/
# Generated / test artifacts
.hammer/
internal/registry/meta_data.json
cmd/api/download.bin
app.log

View File

@@ -746,4 +746,29 @@ func TestShortcutDryRunShapes(t *testing.T) {
t.Fatalf("ImChatMessageList.DryRun().Format() = %s", formatted)
}
})
t.Run("ImChatMessageList dry run includes root-only query", func(t *testing.T) {
runtime := newTestRuntimeContext(t, map[string]string{
"chat-id": "oc_123",
"page-size": "20",
"sort": "desc",
}, nil)
formatted := ImChatMessageList.DryRun(context.Background(), runtime).Format()
if !strings.Contains(formatted, "only_thread_root_messages=true") {
t.Fatalf("ImChatMessageList.DryRun().Format() = %s, want only_thread_root_messages=true", formatted)
}
})
}
func TestChatMessageListOnlyThreadRootMessagesDryRun(t *testing.T) {
runtime := newTestRuntimeContext(t, map[string]string{
"chat-id": "oc_123",
"page-size": "20",
"sort": "desc",
}, nil)
formatted := ImChatMessageList.DryRun(context.Background(), runtime).Format()
if !strings.Contains(formatted, "only_thread_root_messages=true") {
t.Fatalf("ImChatMessageList.DryRun().Format() = %s, want only_thread_root_messages=true", formatted)
}
}

View File

@@ -210,14 +210,15 @@ func TestBuildChatMessageListRequest(t *testing.T) {
}
want := larkcore.QueryParams{
"container_id_type": {"chat"},
"container_id": {"oc_123"},
"sort_type": {"ByCreateTimeAsc"},
"page_size": {"50"},
"card_msg_content_type": {"raw_card_content"},
"start_time": {"1772294400"},
"end_time": {"1772467199"},
"page_token": {"next"},
"container_id_type": {"chat"},
"container_id": {"oc_123"},
"sort_type": {"ByCreateTimeAsc"},
"page_size": {"50"},
"only_thread_root_messages": {"true"},
"card_msg_content_type": {"raw_card_content"},
"start_time": {"1772294400"},
"end_time": {"1772467199"},
"page_token": {"next"},
}
if !reflect.DeepEqual(got, want) {
t.Fatalf("buildChatMessageListRequest() = %#v, want %#v", got, want)
@@ -245,6 +246,13 @@ func TestBuildChatMessageListRequest(t *testing.T) {
})
}
func TestChatMessageListOnlyThreadRootMessagesParams(t *testing.T) {
got := buildChatMessageListParams("desc", "20", "oc_123")
if vals := got["only_thread_root_messages"]; !reflect.DeepEqual(vals, []string{"true"}) {
t.Fatalf("only_thread_root_messages = %#v, want true", vals)
}
}
func TestResolveChatIDForMessagesList(t *testing.T) {
t.Run("chat passthrough", func(t *testing.T) {
runtime := newTestRuntimeContext(t, map[string]string{

View File

@@ -172,11 +172,12 @@ func buildChatMessageListParams(sortFlag, pageSizeStr, chatId string) larkcore.Q
pageSize = min(max(n, 1), 50)
}
return larkcore.QueryParams{
"container_id_type": []string{"chat"},
"container_id": []string{chatId},
"sort_type": []string{sortType},
"page_size": []string{strconv.Itoa(pageSize)},
"card_msg_content_type": []string{"raw_card_content"},
"container_id_type": []string{"chat"},
"container_id": []string{chatId},
"sort_type": []string{sortType},
"page_size": []string{strconv.Itoa(pageSize)},
"card_msg_content_type": []string{"raw_card_content"},
"only_thread_root_messages": []string{"true"},
}
}