1package message
2
3import (
4 "slices"
5 "strings"
6)
7
8type Attachment struct {
9 FilePath string
10 FileName string
11 MimeType string
12 Content []byte
13}
14
15func (a Attachment) IsText() bool { return strings.HasPrefix(a.MimeType, "text/") }
16func (a Attachment) IsImage() bool { return strings.HasPrefix(a.MimeType, "image/") }
17
18// ContainsTextAttachment returns true if any of the attachments is a text attachments.
19func ContainsTextAttachment(attachments []Attachment) bool {
20 return slices.ContainsFunc(attachments, func(a Attachment) bool {
21 return a.IsText()
22 })
23}