From bf56e903ba833416478fb563b017e4dc86f4e859 Mon Sep 17 00:00:00 2001 From: shanglei Date: Mon, 27 Jul 2026 14:37:02 +0800 Subject: [PATCH] docs: point the two brand parsers at each other Removing extension's dependency on internal left the brand rule implemented twice, once per Brand type. The two cannot share code: extension is published as a standalone SDK and may not import internal, which is the constraint this branch exists to establish. Cross-reference them so a third brand is added to both rather than to whichever one the next author happens to open. Also correct the timestamp wrapper's comment, which has claimed "HH:mm" since before this branch while every implementation formatted seconds too. --- extension/credential/types.go | 5 +++++ internal/core/types.go | 4 ++++ shortcuts/im/convert_lib/helpers.go | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/extension/credential/types.go b/extension/credential/types.go index 19a5dc2af..79e980ada 100644 --- a/extension/credential/types.go +++ b/extension/credential/types.go @@ -20,6 +20,11 @@ const ( // It lives next to the Brand constants so every credential source resolves the // brand the same way; duplicating the rule per provider would let one copy // drift when the brand set changes. +// +// internal/core.ParseBrand applies the same rule to core.LarkBrand, which the +// rest of the CLI uses. The two cannot share an implementation: this package is +// published as a standalone SDK and may not import internal. Adding a brand +// means changing both. func ParseBrand(value string) Brand { if strings.ToLower(strings.TrimSpace(value)) == string(BrandLark) { return BrandLark diff --git a/internal/core/types.go b/internal/core/types.go index 29720d4c3..c2bc95d7d 100644 --- a/internal/core/types.go +++ b/internal/core/types.go @@ -17,6 +17,10 @@ const ( // ParseBrand normalizes a brand string (case-insensitive, whitespace-tolerant); // anything other than "lark" normalizes to BrandFeishu. +// +// extension/credential.ParseBrand applies the same rule to its own Brand type. +// The two cannot share an implementation: extension is published as a standalone +// SDK and may not import internal. Adding a brand means changing both. func ParseBrand(value string) LarkBrand { if strings.ToLower(strings.TrimSpace(value)) == "lark" { return BrandLark diff --git a/shortcuts/im/convert_lib/helpers.go b/shortcuts/im/convert_lib/helpers.go index 9ef681cbe..e416e0dc1 100644 --- a/shortcuts/im/convert_lib/helpers.go +++ b/shortcuts/im/convert_lib/helpers.go @@ -24,7 +24,7 @@ func ResolveMentionKeys(text string, mentionMap map[string]string) string { } // formatTimestamp converts a Unix timestamp string (seconds or milliseconds) to -// "YYYY-MM-DD HH:mm" local time. Values with fewer than 10 digits are treated as +// "YYYY-MM-DD HH:mm:ss" local time. Values with fewer than 10 digits are treated as // seconds; larger values are treated as milliseconds. // Returns empty string if the input is empty or unparseable. func formatTimestamp(ts string) string {