diff options
Diffstat (limited to 'commands/msg')
-rw-r--r-- | commands/msg/forward.go | 2 | ||||
-rw-r--r-- | commands/msg/invite.go | 4 | ||||
-rw-r--r-- | commands/msg/recall.go | 48 | ||||
-rw-r--r-- | commands/msg/reply.go | 2 | ||||
-rw-r--r-- | commands/msg/unsubscribe.go | 2 |
5 files changed, 13 insertions, 45 deletions
diff --git a/commands/msg/forward.go b/commands/msg/forward.go index 92575abd..ed0043fe 100644 --- a/commands/msg/forward.go +++ b/commands/msg/forward.go @@ -100,7 +100,7 @@ func (forward) Execute(aerc *widgets.Aerc, args []string) error { addTab := func() (*widgets.Composer, error) { composer, err := widgets.NewComposer(aerc, acct, - acct.AccountConfig(), acct.Worker(), template, h, &original) + acct.AccountConfig(), acct.Worker(), template, h, &original, nil) if err != nil { aerc.PushError("Error: " + err.Error()) return nil, err diff --git a/commands/msg/invite.go b/commands/msg/invite.go index 774c4a69..6273d520 100644 --- a/commands/msg/invite.go +++ b/commands/msg/invite.go @@ -138,13 +138,11 @@ func (invite) Execute(aerc *widgets.Aerc, args []string) error { addTab := func(cr *calendar.Reply) error { composer, err := widgets.NewComposer(aerc, acct, - acct.AccountConfig(), acct.Worker(), "", h, &original) + acct.AccountConfig(), acct.Worker(), "", h, &original, cr.PlainText) if err != nil { aerc.PushError("Error: " + err.Error()) return err } - - composer.SetContents(cr.PlainText) err = composer.AppendPart(cr.MimeType, cr.Params, cr.CalendarText) if err != nil { return fmt.Errorf("failed to write invitation: %w", err) diff --git a/commands/msg/recall.go b/commands/msg/recall.go index 4eda8339..71f8b8a5 100644 --- a/commands/msg/recall.go +++ b/commands/msg/recall.go @@ -7,14 +7,11 @@ import ( "sync" "time" - "github.com/emersion/go-message" _ "github.com/emersion/go-message/charset" - "github.com/emersion/go-message/mail" "github.com/pkg/errors" "git.sr.ht/~rjarry/aerc/lib" "git.sr.ht/~rjarry/aerc/log" - "git.sr.ht/~rjarry/aerc/models" "git.sr.ht/~rjarry/aerc/widgets" "git.sr.ht/~rjarry/aerc/worker/types" "git.sr.ht/~sircmpwn/getopt" @@ -71,17 +68,7 @@ func (Recall) Execute(aerc *widgets.Aerc, args []string) error { } log.Debugf("Recalling message <%s>", msgInfo.Envelope.MessageId) - composer, err := widgets.NewComposer(aerc, acct, - acct.AccountConfig(), acct.Worker(), "", msgInfo.RFC822Headers, - nil) - if err != nil { - return errors.Wrap(err, "Cannot open a new composer") - } - - // focus the terminal since the header fields are likely already done - composer.FocusTerminal() - - addTab := func() { + addTab := func(composer *widgets.Composer) { subject := msgInfo.Envelope.Subject if subject == "" { subject = "Recalled email" @@ -136,39 +123,19 @@ func (Recall) Execute(aerc *widgets.Aerc, args []string) error { aerc.PushError(err.Error()) return } - - var ( - path []int - part *models.BodyStructure - ) + var path []int if len(msg.BodyStructure().Parts) != 0 { path = lib.FindPlaintext(msg.BodyStructure(), path) } - part, err = msg.BodyStructure().PartAtIndex(path) - if part == nil || err != nil { - part = msg.BodyStructure() - } msg.FetchBodyPart(path, func(reader io.Reader) { - header := message.Header{} - header.SetText( - "Content-Transfer-Encoding", part.Encoding) - header.SetContentType(part.MIMEType, part.Params) - header.SetText("Content-Description", part.Description) - entity, err := message.New(header, reader) + composer, err := widgets.NewComposer(aerc, acct, + acct.AccountConfig(), acct.Worker(), + "", msgInfo.RFC822Headers, nil, reader) if err != nil { aerc.PushError(err.Error()) - addTab() return } - mreader := mail.NewReader(entity) - part, err := mreader.NextPart() - if err != nil { - aerc.PushError(err.Error()) - addTab() - return - } - composer.SetContents(part.Body) if md := msg.MessageDetails(); md != nil { if md.IsEncrypted { composer.SetEncrypt(md.IsEncrypted) @@ -180,7 +147,6 @@ func (Recall) Execute(aerc *widgets.Aerc, args []string) error { } } } - addTab() // add attachements if present var mu sync.Mutex @@ -210,6 +176,10 @@ func (Recall) Execute(aerc *widgets.Aerc, args []string) error { } }) } + + // focus the terminal since the header fields are likely already done + composer.FocusTerminal() + addTab(composer) }) }) diff --git a/commands/msg/reply.go b/commands/msg/reply.go index 2b9f5d4f..8cdb50d4 100644 --- a/commands/msg/reply.go +++ b/commands/msg/reply.go @@ -176,7 +176,7 @@ func (reply) Execute(aerc *widgets.Aerc, args []string) error { addTab := func() error { composer, err := widgets.NewComposer(aerc, acct, acct.AccountConfig(), acct.Worker(), template, h, - &original) + &original, nil) if err != nil { aerc.PushError("Error: " + err.Error()) return err diff --git a/commands/msg/unsubscribe.go b/commands/msg/unsubscribe.go index 5fce7ece..cefa69cb 100644 --- a/commands/msg/unsubscribe.go +++ b/commands/msg/unsubscribe.go @@ -154,11 +154,11 @@ func unsubscribeMailto(aerc *widgets.Aerc, u *url.URL) error { "", h, nil, + strings.NewReader(u.Query().Get("body")), ) if err != nil { return err } - composer.SetContents(strings.NewReader(u.Query().Get("body"))) composer.Tab = aerc.NewTab(composer, "unsubscribe") composer.FocusTerminal() return nil |