aboutsummaryrefslogtreecommitdiff
path: root/server.go
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2019-12-03 16:46:03 +0100
committerSimon Ser <contact@emersion.fr>2019-12-03 16:46:03 +0100
commit36923a0dc23567e58e9c38f6e7ba96b8bf41db68 (patch)
treee8d61a5a6f8a7d525be2dfe691e35d163ae7221e /server.go
parent89cebfd8199d172058ff89cd8586ed12866139e0 (diff)
downloadalps-36923a0dc23567e58e9c38f6e7ba96b8bf41db68.tar.gz
alps-36923a0dc23567e58e9c38f6e7ba96b8bf41db68.zip
Pre-fill composer with sender address
Diffstat (limited to 'server.go')
-rw-r--r--server.go20
1 files changed, 13 insertions, 7 deletions
diff --git a/server.go b/server.go
index 6a12122..c4eb6d7 100644
--- a/server.go
+++ b/server.go
@@ -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 {