summaryrefslogtreecommitdiffhomepage
path: root/packages/tui/internal/attachment
diff options
context:
space:
mode:
Diffstat (limited to 'packages/tui/internal/attachment')
-rw-r--r--packages/tui/internal/attachment/attachment.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/packages/tui/internal/attachment/attachment.go b/packages/tui/internal/attachment/attachment.go
index 178de9954..26bb91d49 100644
--- a/packages/tui/internal/attachment/attachment.go
+++ b/packages/tui/internal/attachment/attachment.go
@@ -4,6 +4,10 @@ import (
"github.com/google/uuid"
)
+type TextSource struct {
+ Value string `toml:"value"`
+}
+
type FileSource struct {
Path string `toml:"path"`
Mime string `toml:"mime"`
@@ -46,6 +50,14 @@ func NewAttachment() *Attachment {
}
}
+func (a *Attachment) GetTextSource() (*TextSource, bool) {
+ if a.Type != "text" {
+ return nil, false
+ }
+ ts, ok := a.Source.(*TextSource)
+ return ts, ok
+}
+
// GetFileSource returns the source as FileSource if the attachment is a file type
func (a *Attachment) GetFileSource() (*FileSource, bool) {
if a.Type != "file" {