summary refs log tree commit diff stats
path: root/worker
diff options
context:
space:
mode:
Diffstat (limited to 'worker')
-rw-r--r--worker/imap/fetch.go41
-rw-r--r--worker/imap/list.go9
-rw-r--r--worker/imap/worker.go29
-rw-r--r--worker/types/messages.go25
4 files changed, 55 insertions, 49 deletions
diff --git a/worker/imap/fetch.go b/worker/imap/fetch.go
index 7d1bfcf..d5bb9aa 100644
--- a/worker/imap/fetch.go
+++ b/worker/imap/fetch.go
@@ -8,6 +8,7 @@ import (
 	"github.com/emersion/go-message/mail"
 	"github.com/emersion/go-message/textproto"
 
+	"git.sr.ht/~sircmpwn/aerc/models"
 	"git.sr.ht/~sircmpwn/aerc/worker/types"
 )
 
@@ -82,39 +83,49 @@ func (imapw *IMAPWorker) handleFetchMessages(
 					header = &mail.Header{message.Header{textprotoHeader}}
 				}
 				imapw.worker.PostMessage(&types.MessageInfo{
-					Message:       types.RespondTo(msg),
-					BodyStructure: _msg.BodyStructure,
-					Envelope:      _msg.Envelope,
-					Flags:         _msg.Flags,
-					InternalDate:  _msg.InternalDate,
-					RFC822Headers: header,
-					Uid:           _msg.Uid,
+					Message: types.RespondTo(msg),
+					Info: &models.MessageInfo{
+						BodyStructure: _msg.BodyStructure,
+						Envelope:      _msg.Envelope,
+						Flags:         _msg.Flags,
+						InternalDate:  _msg.InternalDate,
+						RFC822Headers: header,
+						Uid:           _msg.Uid,
+					},
 				}, nil)
 			case *types.FetchFullMessages:
 				reader := _msg.GetBody(section)
 				imapw.worker.PostMessage(&types.FullMessage{
 					Message: types.RespondTo(msg),
-					Reader:  reader,
-					Uid:     _msg.Uid,
+					Content: &models.FullMessage{
+						Reader: reader,
+						Uid:    _msg.Uid,
+					},
 				}, nil)
 				// Update flags (to mark message as read)
 				imapw.worker.PostMessage(&types.MessageInfo{
 					Message: types.RespondTo(msg),
-					Flags:   _msg.Flags,
-					Uid:     _msg.Uid,
+					Info: &models.MessageInfo{
+						Flags: _msg.Flags,
+						Uid:   _msg.Uid,
+					},
 				}, nil)
 			case *types.FetchMessageBodyPart:
 				reader := _msg.GetBody(section)
 				imapw.worker.PostMessage(&types.MessageBodyPart{
 					Message: types.RespondTo(msg),
-					Reader:  reader,
-					Uid:     _msg.Uid,
+					Part: &models.MessageBodyPart{
+						Reader: reader,
+						Uid:    _msg.Uid,
+					},
 				}, nil)
 				// Update flags (to mark message as read)
 				imapw.worker.PostMessage(&types.MessageInfo{
 					Message: types.RespondTo(msg),
-					Flags:   _msg.Flags,
-					Uid:     _msg.Uid,
+					Info: &models.MessageInfo{
+						Flags: _msg.Flags,
+						Uid:   _msg.Uid,
+					},
 				}, nil)
 			}
 		}
diff --git a/worker/imap/list.go b/worker/imap/list.go
index 708e70f..42be50e 100644
--- a/worker/imap/list.go
+++ b/worker/imap/list.go
@@ -3,6 +3,7 @@ package imap
 import (
 	"github.com/emersion/go-imap"
 
+	"git.sr.ht/~sircmpwn/aerc/models"
 	"git.sr.ht/~sircmpwn/aerc/worker/types"
 )
 
@@ -18,9 +19,11 @@ func (imapw *IMAPWorker) handleListDirectories(msg *types.ListDirectories) {
 				continue
 			}
 			imapw.worker.PostMessage(&types.Directory{
-				Message:    types.RespondTo(msg),
-				Name:       mbox.Name,
-				Attributes: mbox.Attributes,
+				Message: types.RespondTo(msg),
+				Dir: &models.Directory{
+					Name:       mbox.Name,
+					Attributes: mbox.Attributes,
+				},
 			}, nil)
 		}
 		done <- nil
diff --git a/worker/imap/worker.go b/worker/imap/worker.go
index 5005620..9ddaa47 100644
--- a/worker/imap/worker.go
+++ b/worker/imap/worker.go
@@ -10,6 +10,7 @@ import (
 	idle "github.com/emersion/go-imap-idle"
 	"github.com/emersion/go-imap/client"
 
+	"git.sr.ht/~sircmpwn/aerc/models"
 	"git.sr.ht/~sircmpwn/aerc/worker/types"
 )
 
@@ -169,13 +170,15 @@ func (w *IMAPWorker) handleImapUpdate(update client.Update) {
 			w.selected = *status
 		}
 		w.worker.PostMessage(&types.DirectoryInfo{
-			Flags:    status.Flags,
-			Name:     status.Name,
-			ReadOnly: status.ReadOnly,
-
-			Exists: int(status.Messages),
-			Recent: int(status.Recent),
-			Unseen: int(status.Unseen),
+			Info: &models.DirectoryInfo{
+				Flags:    status.Flags,
+				Name:     status.Name,
+				ReadOnly: status.ReadOnly,
+
+				Exists: int(status.Messages),
+				Recent: int(status.Recent),
+				Unseen: int(status.Unseen),
+			},
 		}, nil)
 	case *client.MessageUpdate:
 		msg := update.Message
@@ -183,11 +186,13 @@ func (w *IMAPWorker) handleImapUpdate(update client.Update) {
 			msg.Uid = w.seqMap[msg.SeqNum-1]
 		}
 		w.worker.PostMessage(&types.MessageInfo{
-			BodyStructure: msg.BodyStructure,
-			Envelope:      msg.Envelope,
-			Flags:         msg.Flags,
-			InternalDate:  msg.InternalDate,
-			Uid:           msg.Uid,
+			Info: &models.MessageInfo{
+				BodyStructure: msg.BodyStructure,
+				Envelope:      msg.Envelope,
+				Flags:         msg.Flags,
+				InternalDate:  msg.InternalDate,
+				Uid:           msg.Uid,
+			},
 		}, nil)
 	case *client.ExpungeUpdate:
 		i := update.SeqNum - 1
diff --git a/worker/types/messages.go b/worker/types/messages.go
index d9e911f..bb2505a 100644
--- a/worker/types/messages.go
+++ b/worker/types/messages.go
@@ -5,9 +5,9 @@ import (
 	"time"
 
 	"github.com/emersion/go-imap"
-	"github.com/emersion/go-message/mail"
 
 	"git.sr.ht/~sircmpwn/aerc/config"
+	"git.sr.ht/~sircmpwn/aerc/models"
 )
 
 type WorkerMessage interface {
@@ -139,17 +139,12 @@ type AppendMessage struct {
 
 type Directory struct {
 	Message
-	Attributes []string
-	Name       string
+	Dir *models.Directory
 }
 
 type DirectoryInfo struct {
 	Message
-	Flags    []string
-	Name     string
-	ReadOnly bool
-
-	Exists, Recent, Unseen int
+	Info *models.DirectoryInfo
 }
 
 type DirectoryContents struct {
@@ -164,25 +159,17 @@ type SearchResults struct {
 
 type MessageInfo struct {
 	Message
-	BodyStructure *imap.BodyStructure
-	Envelope      *imap.Envelope
-	Flags         []string
-	InternalDate  time.Time
-	RFC822Headers *mail.Header
-	Size          uint32
-	Uid           uint32
+	Info *models.MessageInfo
 }
 
 type FullMessage struct {
 	Message
-	Reader io.Reader
-	Uid    uint32
+	Content *models.FullMessage
 }
 
 type MessageBodyPart struct {
 	Message
-	Reader io.Reader
-	Uid    uint32
+	Part *models.MessageBodyPart
 }
 
 type MessagesDeleted struct {