about summary refs log tree commit diff stats
path: root/models
diff options
context:
space:
mode:
authorBen Burwell <ben@benburwell.com>2019-07-07 22:43:56 -0400
committerDrew DeVault <sir@cmpwn.com>2019-07-08 16:06:23 -0400
commitcce7cb48081ca090ac2d3a0e781dfbc25d581946 (patch)
tree0709eff3daf75ac975bc9e12f068d7951aeaefe6 /models
parentc79577d37675c8d9ed3355c532a215377e76d3b2 (diff)
downloadaerc-cce7cb48081ca090ac2d3a0e781dfbc25d581946.tar.gz
Factor UI models out of the worker message package
Before, the information needed to display different parts of the UI was
tightly coupled to the specific messages being sent back and forth to
the backend worker. Separating out a models package allows us to be more
specific about exactly what a backend is able to and required to
provide for the UI.
Diffstat (limited to 'models')
-rw-r--r--models/models.go52
1 files changed, 52 insertions, 0 deletions
diff --git a/models/models.go b/models/models.go
new file mode 100644
index 0000000..cff05b1
--- /dev/null
+++ b/models/models.go
@@ -0,0 +1,52 @@
+package models
+
+import (
+	"io"
+	"time"
+
+	"github.com/emersion/go-imap"
+	"github.com/emersion/go-message/mail"
+)
+
+type Directory struct {
+	Name       string
+	Attributes []string
+}
+
+type DirectoryInfo struct {
+	Name     string
+	Flags    []string
+	ReadOnly bool
+
+	// The total number of messages in this mailbox.
+	Exists int
+
+	// The number of messages not seen since the last time the mailbox was opened.
+	Recent int
+
+	// The number of unread messages
+	Unseen int
+}
+
+// A MessageInfo holds information about the structure of a message
+type MessageInfo struct {
+	BodyStructure *imap.BodyStructure
+	Envelope      *imap.Envelope
+	Flags         []string
+	InternalDate  time.Time
+	RFC822Headers *mail.Header
+	Size          uint32
+	Uid           uint32
+}
+
+// A MessageBodyPart can be displayed in the message viewer
+type MessageBodyPart struct {
+	Reader io.Reader
+	Uid    uint32
+}
+
+// A FullMessage is the entire message
+type FullMessage struct {
+	Reader io.Reader
+	Uid    uint32
+}