mirror of
https://github.com/paymog/slack-cli.git
synced 2026-09-18 23:43:49 +08:00
fix: include attachment TitleLink in message text output
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
committed by
Dmitrii Korotovskii
parent
d9213df8f9
commit
d3f7ca3a4a
@@ -18,7 +18,11 @@ func AttachmentToText(att slack.Attachment) string {
|
||||
var parts []string
|
||||
|
||||
if att.Title != "" {
|
||||
parts = append(parts, fmt.Sprintf("Title: %s", att.Title))
|
||||
if att.TitleLink != "" {
|
||||
parts = append(parts, fmt.Sprintf("Title: [%s](%s)", att.Title, att.TitleLink))
|
||||
} else {
|
||||
parts = append(parts, fmt.Sprintf("Title: %s", att.Title))
|
||||
}
|
||||
}
|
||||
|
||||
if att.AuthorName != "" {
|
||||
|
||||
@@ -400,6 +400,21 @@ func TestAttachmentToText(t *testing.T) {
|
||||
},
|
||||
want: "",
|
||||
},
|
||||
{
|
||||
name: "title_with_link",
|
||||
att: slack.Attachment{
|
||||
Title: "Error details",
|
||||
TitleLink: "https://sentry.io/issues/123",
|
||||
},
|
||||
want: "Title: [Error details][https://sentry.io/issues/123]",
|
||||
},
|
||||
{
|
||||
name: "title_without_link",
|
||||
att: slack.Attachment{
|
||||
Title: "Plain title",
|
||||
},
|
||||
want: "Title: Plain title",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
||||
Reference in New Issue
Block a user