diff options
author | Simon Ser <contact@emersion.fr> | 2019-12-03 16:46:03 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2019-12-03 16:46:03 +0100 |
commit | 36923a0dc23567e58e9c38f6e7ba96b8bf41db68 (patch) | |
tree | e8d61a5a6f8a7d525be2dfe691e35d163ae7221e /server.go | |
parent | 89cebfd8199d172058ff89cd8586ed12866139e0 (diff) | |
download | alps-36923a0dc23567e58e9c38f6e7ba96b8bf41db68.tar.gz alps-36923a0dc23567e58e9c38f6e7ba96b8bf41db68.zip |
Pre-fill composer with sender address
Diffstat (limited to 'server.go')
-rw-r--r-- | server.go | 20 |
1 files changed, 13 insertions, 7 deletions
@@ -202,6 +202,11 @@ func handleGetPart(ctx *context, raw bool) error { func handleCompose(ectx echo.Context) error { ctx := ectx.(*context) + var msg OutgoingMessage + if strings.ContainsRune(ctx.session.username, '@') { + msg.From = ctx.session.username + } + if ctx.Request().Method == http.MethodPost { // TODO: parse address lists from := ctx.FormValue("from") @@ -220,12 +225,11 @@ func handleCompose(ectx echo.Context) error { return echo.NewHTTPError(http.StatusForbidden, err) } - msg := OutgoingMessage{ - from: from, - to: []string{to}, - subject: subject, - text: text, - } + msg.From = from + msg.To = []string{to} + msg.Subject = subject + msg.Text = text + if err := sendMessage(c, &msg); err != nil { return err } @@ -239,7 +243,9 @@ func handleCompose(ectx echo.Context) error { return ctx.Redirect(http.StatusFound, "/mailbox/INBOX") } - return ctx.Render(http.StatusOK, "compose.html", nil) + return ctx.Render(http.StatusOK, "compose.html", map[string]interface{}{ + "Message": &msg, + }) } func New(imapURL, smtpURL string) *echo.Echo { |