mirror of
https://github.com/charmbracelet/crush.git
synced 2026-05-30 18:47:33 +00:00
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
24 lines
559 B
Go
24 lines
559 B
Go
package message
|
|
|
|
import (
|
|
"slices"
|
|
"strings"
|
|
)
|
|
|
|
type Attachment struct {
|
|
FilePath string
|
|
FileName string
|
|
MimeType string
|
|
Content []byte
|
|
}
|
|
|
|
func (a Attachment) IsText() bool { return strings.HasPrefix(a.MimeType, "text/") }
|
|
func (a Attachment) IsImage() bool { return strings.HasPrefix(a.MimeType, "image/") }
|
|
|
|
// ContainsTextAttachment returns true if any of the attachments is a text attachment.
|
|
func ContainsTextAttachment(attachments []Attachment) bool {
|
|
return slices.ContainsFunc(attachments, func(a Attachment) bool {
|
|
return a.IsText()
|
|
})
|
|
}
|