diff options
author | Drew DeVault <sir@cmpwn.com> | 2019-03-31 11:29:57 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-03-31 11:29:57 -0400 |
commit | 143289bbd0736d72553a3c2a080aa3d125366b38 (patch) | |
tree | 6a2e97db785db1385063323708764cb93388a4d0 /commands/account | |
parent | 1f23868652a2ce0e81bddd048e3e828efaff2d69 (diff) | |
download | aerc-143289bbd0736d72553a3c2a080aa3d125366b38.tar.gz |
Don't parse mail in worker; send a reader instead
Diffstat (limited to 'commands/account')
-rw-r--r-- | commands/account/fetch-msg.go | 29 | ||||
-rw-r--r-- | commands/account/pipe.go | 7 |
2 files changed, 2 insertions, 34 deletions
diff --git a/commands/account/fetch-msg.go b/commands/account/fetch-msg.go deleted file mode 100644 index 631a8eed..00000000 --- a/commands/account/fetch-msg.go +++ /dev/null @@ -1,29 +0,0 @@ -package account - -import ( - "errors" - - "github.com/mohamedattahri/mail" - - "git.sr.ht/~sircmpwn/aerc2/widgets" -) - -func init() { - register("fetch-message", FetchMessage) -} - -func FetchMessage(aerc *widgets.Aerc, args []string) error { - if len(args) != 1 { - return errors.New("Usage: :fetch-message") - } - acct := aerc.SelectedAccount() - if acct == nil { - return errors.New("No account selected") - } - store := acct.Messages().Store() - msg := acct.Messages().Selected() - store.FetchBodies([]uint32{msg.Uid}, func(msg *mail.Message) { - aerc.SetStatus("got message body, woohoo") - }) - return nil -} diff --git a/commands/account/pipe.go b/commands/account/pipe.go index 60ac7932..b07a860d 100644 --- a/commands/account/pipe.go +++ b/commands/account/pipe.go @@ -1,7 +1,6 @@ package account import ( - "bytes" "errors" "io" "os/exec" @@ -10,7 +9,6 @@ import ( "git.sr.ht/~sircmpwn/aerc2/widgets" "github.com/gdamore/tcell" - "github.com/mohamedattahri/mail" ) func init() { @@ -27,7 +25,7 @@ func Pipe(aerc *widgets.Aerc, args []string) error { } store := acct.Messages().Store() msg := acct.Messages().Selected() - store.FetchBodies([]uint32{msg.Uid}, func(msg *mail.Message) { + store.FetchBodies([]uint32{msg.Uid}, func(reader io.Reader) { cmd := exec.Command(args[1], args[2:]...) pipe, err := cmd.StdinPipe() if err != nil { @@ -41,7 +39,7 @@ func Pipe(aerc *widgets.Aerc, args []string) error { Color(tcell.ColorDefault, tcell.ColorRed) return } - name := msg.Subject() + name := msg.Envelope.Subject if len(name) > 12 { name = name[:12] } @@ -58,7 +56,6 @@ func Pipe(aerc *widgets.Aerc, args []string) error { } term.OnStart = func() { go func() { - reader := bytes.NewBuffer(msg.Bytes()) _, err := io.Copy(pipe, reader) if err != nil { aerc.PushStatus(" "+err.Error(), 10*time.Second). |