From 6c78db7467d17035e049ea5794656cd4dc224ec6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=95=BF=E7=9C=9F?= Date: Thu, 13 Aug 2026 23:36:53 +0800 Subject: [PATCH] fix(chat): document Shanghai time message default --- internal/helpers/chat.go | 2 +- internal/helpers/chat_message_help_test.go | 4 ++-- internal/helpers/im_read_result_contract_test.go | 7 ++++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/internal/helpers/chat.go b/internal/helpers/chat.go index 267574de..f36dd104 100644 --- a/internal/helpers/chat.go +++ b/internal/helpers/chat.go @@ -2663,7 +2663,7 @@ func newChatCommand() *cobra.Command { chatMessageListCmd := &cobra.Command{ Use: "list", Short: "拉取会话消息内容", - Long: `拉取指定群聊或单聊的会话消息内容。输出顶层 messages,稳定字段为 messageId 和 text;兼容保留 openMessageId 和 content。--group 指定群聊,--user 指定单聊用户(userId),--open-dingtalk-id 指定单聊用户(openDingTalkId),三者互斥。--time 可选,不传时默认当前时间并向旧消息拉取。推荐使用 --direction newer/older 控制时间方向:newer 表示从给定时间往现在拉,older 表示从给定时间往以前拉。hasMore=true 时用结果中的边界 createTime 作为下次 --time 翻页。引用回复消息会返回 quotedMessage 引用上下文;被引用的原消息是合并转发或图片时,对应的类型与内容也会随引用上下文返回。如果返回的会话消息中包含 openConvThreadId 字段,说明是话题消息,可以调用 dws chat message list-topic-replies 拉取话题回复消息列表,openConvThreadId 作为 topic-id 参数。`, + Long: `拉取指定群聊或单聊的会话消息内容。输出顶层 messages,稳定字段为 messageId 和 text;兼容保留 openMessageId 和 content。--group 指定群聊,--user 指定单聊用户(userId),--open-dingtalk-id 指定单聊用户(openDingTalkId),三者互斥。--time 可选,不传时默认上海时间当前时间并向旧消息拉取。推荐使用 --direction newer/older 控制时间方向:newer 表示从给定时间往现在拉,older 表示从给定时间往以前拉。hasMore=true 时用结果中的边界 createTime 作为下次 --time 翻页。引用回复消息会返回 quotedMessage 引用上下文;被引用的原消息是合并转发或图片时,对应的类型与内容也会随引用上下文返回。如果返回的会话消息中包含 openConvThreadId 字段,说明是话题消息,可以调用 dws chat message list-topic-replies 拉取话题回复消息列表,openConvThreadId 作为 topic-id 参数。`, Example: ` dws chat message list --group dws chat message list --group --time "2025-03-01 00:00:00" dws chat message list --user --time "2025-03-01 00:00:00" --limit 50 diff --git a/internal/helpers/chat_message_help_test.go b/internal/helpers/chat_message_help_test.go index 6941e2e8..9e528d3c 100644 --- a/internal/helpers/chat_message_help_test.go +++ b/internal/helpers/chat_message_help_test.go @@ -102,8 +102,8 @@ func TestCrossPlatformCoverageChatMessageHelpDocumentsOptionalTimeDefaults(t *te name: "list", args: []string{"message", "list", "--help"}, contains: []string{ - "--time 可选,不传时默认当前时间并向旧消息拉取", - "默认当前时间", + "--time 可选,不传时默认上海时间当前时间并向旧消息拉取", + "默认上海时间当前时间", "未传 --time 时默认 older", }, absent: []string{"开始时间,格式: yyyy-MM-dd HH:mm:ss (必填)"}, diff --git a/internal/helpers/im_read_result_contract_test.go b/internal/helpers/im_read_result_contract_test.go index 0d983925..9494069d 100644 --- a/internal/helpers/im_read_result_contract_test.go +++ b/internal/helpers/im_read_result_contract_test.go @@ -213,11 +213,12 @@ func TestCrossPlatformCoverageChatMessageListProjectsStableFieldsAndPreservesLeg func TestCrossPlatformCoverageChatMessageListDefaultsTimeAndOlderDirection(t *testing.T) { payload := `{"result":{"messages":[],"hasMore":false}}` caller := &imReadResultCaller{responses: map[string]string{"list_conversation_message_v2": payload}} + loc := shanghaiLocation() - before := time.Now() + before := time.Now().In(loc) _, err := executeIMReadCommand(t, caller, []string{"dws", "chat"}, newChatCommand, "message", "list", "--group", "cid-1", "--limit", "50") - after := time.Now() + after := time.Now().In(loc) if err != nil { t.Fatalf("chat message list returned error: %v", err) } @@ -231,7 +232,7 @@ func TestCrossPlatformCoverageChatMessageListDefaultsTimeAndOlderDirection(t *te if !ok || strings.TrimSpace(timeRaw) == "" { t.Fatalf("time arg = %#v, want generated current time", caller.args["time"]) } - gotTime, err := time.ParseInLocation("2006-01-02 15:04:05", timeRaw, time.Local) + gotTime, err := time.ParseInLocation("2006-01-02 15:04:05", timeRaw, loc) if err != nil { t.Fatalf("parse generated time %q: %v", timeRaw, err) }