aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--commands/msg/forward.go6
-rw-r--r--commands/msg/pipe.go7
-rw-r--r--lib/messageview.go4
-rw-r--r--lib/msgstore.go10
-rw-r--r--worker/types/messages.go1
5 files changed, 17 insertions, 11 deletions
diff --git a/commands/msg/forward.go b/commands/msg/forward.go
index 35a65d8e..0b81e520 100644
--- a/commands/msg/forward.go
+++ b/commands/msg/forward.go
@@ -12,6 +12,8 @@ import (
"git.sr.ht/~sircmpwn/aerc/models"
"git.sr.ht/~sircmpwn/aerc/widgets"
+ "git.sr.ht/~sircmpwn/aerc/worker/types"
+
"git.sr.ht/~sircmpwn/getopt"
)
@@ -109,7 +111,7 @@ func (forward) Execute(aerc *widgets.Aerc, args []string) error {
}
tmpFileName := path.Join(tmpDir,
strings.ReplaceAll(fmt.Sprintf("%s.eml", msg.Envelope.Subject), "/", "-"))
- store.FetchFull([]uint32{msg.Uid}, func(reader io.Reader) {
+ store.FetchFull([]uint32{msg.Uid}, func(fm *types.FullMessage) {
tmpFile, err := os.Create(tmpFileName)
if err != nil {
println(err)
@@ -119,7 +121,7 @@ func (forward) Execute(aerc *widgets.Aerc, args []string) error {
}
defer tmpFile.Close()
- io.Copy(tmpFile, reader)
+ io.Copy(tmpFile, fm.Content.Reader)
composer, err := addTab()
if err != nil {
return
diff --git a/commands/msg/pipe.go b/commands/msg/pipe.go
index 9fbc3acc..44b0067d 100644
--- a/commands/msg/pipe.go
+++ b/commands/msg/pipe.go
@@ -9,6 +9,7 @@ import (
"git.sr.ht/~sircmpwn/aerc/commands"
"git.sr.ht/~sircmpwn/aerc/widgets"
+ "git.sr.ht/~sircmpwn/aerc/worker/types"
"git.sr.ht/~sircmpwn/getopt"
"github.com/gdamore/tcell"
@@ -115,11 +116,11 @@ func (Pipe) Execute(aerc *widgets.Aerc, args []string) error {
if err != nil {
return err
}
- store.FetchFull([]uint32{msg.Uid}, func(reader io.Reader) {
+ store.FetchFull([]uint32{msg.Uid}, func(fm *types.FullMessage) {
if background {
- doExec(reader)
+ doExec(fm.Content.Reader)
} else {
- doTerm(reader, fmt.Sprintf(
+ doTerm(fm.Content.Reader, fmt.Sprintf(
"%s <%s", cmd[0], msg.Envelope.Subject))
}
})
diff --git a/lib/messageview.go b/lib/messageview.go
index be3b90ff..3bf133aa 100644
--- a/lib/messageview.go
+++ b/lib/messageview.go
@@ -12,6 +12,7 @@ import (
"git.sr.ht/~sircmpwn/aerc/models"
"git.sr.ht/~sircmpwn/aerc/worker/lib"
+ "git.sr.ht/~sircmpwn/aerc/worker/types"
)
// This is an abstraction for viewing a message with semi-transparent PGP
@@ -65,7 +66,8 @@ func NewMessageStoreView(messageInfo *models.MessageInfo,
nil, nil, messageInfo.BodyStructure}
if usePGP(messageInfo.BodyStructure) {
- store.FetchFull([]uint32{messageInfo.Uid}, func(reader io.Reader) {
+ store.FetchFull([]uint32{messageInfo.Uid}, func(fm *types.FullMessage) {
+ reader := fm.Content.Reader
pgpReader, err := pgpmail.Read(reader, Keyring, decryptKeys, nil)
if err != nil {
panic(err)
diff --git a/lib/msgstore.go b/lib/msgstore.go
index 481fcb93..b3a86b38 100644
--- a/lib/msgstore.go
+++ b/lib/msgstore.go
@@ -20,7 +20,7 @@ type MessageStore struct {
uids []uint32
selected int
- bodyCallbacks map[uint32][]func(io.Reader)
+ bodyCallbacks map[uint32][]func(*types.FullMessage)
headerCallbacks map[uint32][]func(*types.MessageInfo)
//marking
@@ -64,7 +64,7 @@ func NewMessageStore(worker *types.Worker,
selected: 0,
marked: make(map[uint32]struct{}),
- bodyCallbacks: make(map[uint32][]func(io.Reader)),
+ bodyCallbacks: make(map[uint32][]func(*types.FullMessage)),
headerCallbacks: make(map[uint32][]func(*types.MessageInfo)),
defaultSortCriteria: defaultSortCriteria,
@@ -105,7 +105,7 @@ func (store *MessageStore) FetchHeaders(uids []uint32,
}
}
-func (store *MessageStore) FetchFull(uids []uint32, cb func(io.Reader)) {
+func (store *MessageStore) FetchFull(uids []uint32, cb func(*types.FullMessage)) {
// TODO: this could be optimized by pre-allocating toFetch and trimming it
// at the end. In practice we expect to get most messages back in one frame.
var toFetch []uint32
@@ -117,7 +117,7 @@ func (store *MessageStore) FetchFull(uids []uint32, cb func(io.Reader)) {
if list, ok := store.bodyCallbacks[uid]; ok {
store.bodyCallbacks[uid] = append(list, cb)
} else {
- store.bodyCallbacks[uid] = []func(io.Reader){cb}
+ store.bodyCallbacks[uid] = []func(*types.FullMessage){cb}
}
}
}
@@ -233,7 +233,7 @@ func (store *MessageStore) Update(msg types.WorkerMessage) {
delete(store.pendingBodies, msg.Content.Uid)
if cbs, ok := store.bodyCallbacks[msg.Content.Uid]; ok {
for _, cb := range cbs {
- cb(msg.Content.Reader)
+ cb(msg)
}
delete(store.bodyCallbacks, msg.Content.Uid)
}
diff --git a/worker/types/messages.go b/worker/types/messages.go
index e8205858..6422ef54 100644
--- a/worker/types/messages.go
+++ b/worker/types/messages.go
@@ -166,6 +166,7 @@ type MessageInfo struct {
type FullMessage struct {
Message
+ Info *models.MessageInfo
Content *models.FullMessage
}