Show URL with the attachment of type link

This commit is contained in:
Melroy van den Berg 2025-04-24 17:21:57 +02:00
parent bdb8dbbdc4
commit 4a2a9c7cdf
No known key found for this signature in database
GPG key ID: 71D11FF23454B9D7

View file

@ -131,6 +131,7 @@ func formatContent(jsonStr string, parts []string, bold, green, yellow func(a ..
attachmentType := attachment.Get("type").String()
mediaType := attachment.Get("mediaType").String()
url := attachment.Get("url").String()
href := attachment.Get("href").String()
name := attachment.Get("name").String()
// Truncate long descriptions
@ -147,7 +148,11 @@ func formatContent(jsonStr string, parts []string, bold, green, yellow func(a ..
}
parts = append(parts, attachmentInfo)
if url != "" {
// For type Page and attachment type Link, show href if present
objectType := gjson.Get(jsonStr, "type").String()
if objectType == "Page" && attachmentType == "Link" && href != "" {
parts = append(parts, fmt.Sprintf(" URL: %s", green(href)))
} else if url != "" {
parts = append(parts, fmt.Sprintf(" URL: %s", green(url)))
}
}