aboutsummaryrefslogtreecommitdiff
path: root/worker/imap
diff options
context:
space:
mode:
authorBen Burwell <ben@benburwell.com>2019-07-03 16:10:16 -0400
committerBen Burwell <ben@benburwell.com>2019-07-04 22:03:04 -0400
commit91529df0fecc68d5b0fdbb682529ee545884e7c5 (patch)
tree45b64884521d2df84dc057c99919f03240600344 /worker/imap
parentf9f523ad59491eda08003ce2ccc6d57d7f19ea1e (diff)
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 'worker/imap')
-rw-r--r--worker/imap/fetch.go41
-rw-r--r--worker/imap/worker.go13
2 files changed, 34 insertions, 20 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/worker.go b/worker/imap/worker.go
index 5005620..ff02a78 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"
)
@@ -183,11 +184,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