diff options
author | 2020-11-13 11:55:56 -0500 | |
---|---|---|
committer | 2020-11-13 11:55:56 -0500 | |
commit | 1321cea241e0fa3f3ac7da38b7364b46e0858f11 (patch) | |
tree | aa911c04a4797097ac78483ba2799c82c222e4a8 /plugins/base/routes.go | |
parent | 12547e26540a123f72df347bb87f6d9505480ac2 (diff) | |
download | alps-1321cea241e0fa3f3ac7da38b7364b46e0858f11.tar.gz alps-1321cea241e0fa3f3ac7da38b7364b46e0858f11.tar.bz2 alps-1321cea241e0fa3f3ac7da38b7364b46e0858f11.zip |
Redirect to edit draft after saving message
Diffstat (limited to 'plugins/base/routes.go')
-rw-r--r-- | plugins/base/routes.go | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/plugins/base/routes.go b/plugins/base/routes.go index 6ffdcf6..1f3b8b4 100644 --- a/plugins/base/routes.go +++ b/plugins/base/routes.go @@ -507,7 +507,7 @@ func submitCompose(ctx *alps.Context, msg *OutgoingMessage, options *composeOpti } err = ctx.Session.DoIMAP(func(c *imapclient.Client) error { - if _, err := appendMessage(c, msg, mailboxSent); err != nil { + if _, _, err := appendMessage(c, msg, mailboxSent); err != nil { return err } if draft := options.Draft; draft != nil { @@ -620,14 +620,15 @@ func handleCompose(ctx *alps.Context, msg *OutgoingMessage, options *composeOpti } if saveAsDraft { + var ( + drafts *MailboxInfo + uid uint32 + ) err = ctx.Session.DoIMAP(func(c *imapclient.Client) error { - copied, err := appendMessage(c, msg, mailboxDrafts) + drafts, uid, err = appendMessage(c, msg, mailboxDrafts) if err != nil { return err } - if !copied { - return fmt.Errorf("no Draft mailbox found") - } if draft := options.Draft; draft != nil { if err := deleteMessage(c, draft.Mailbox, draft.Uid); err != nil { return err @@ -638,7 +639,8 @@ func handleCompose(ctx *alps.Context, msg *OutgoingMessage, options *composeOpti if err != nil { return fmt.Errorf("failed to save message to Draft mailbox: %v", err) } - return ctx.Redirect(http.StatusFound, "/mailbox/INBOX") + return ctx.Redirect(http.StatusFound, fmt.Sprintf( + "/message/%s/%d/edit?part=1", drafts.Name, uid)) } else { return submitCompose(ctx, msg, options) } |