diff options
-rw-r--r-- | plugins/base/public/message.html | 16 | ||||
-rw-r--r-- | plugins/base/routes.go | 5 | ||||
-rw-r--r-- | plugins/base/template.go | 8 |
3 files changed, 17 insertions, 12 deletions
diff --git a/plugins/base/public/message.html b/plugins/base/public/message.html index 56e6e6f..b41ae39 100644 --- a/plugins/base/public/message.html +++ b/plugins/base/public/message.html @@ -49,24 +49,32 @@ </form> {{end}} +{{define "addr-list"}} + {{range $i := .}} + {{if $i}},{{end}} + {{.PersonalName}} + <<a href="/compose?to={{.Address}}">{{.Address}}</a>> + {{end}} +{{end}} + <ul> <li> <strong>Date</strong>: {{.Message.Envelope.Date | formatdate}} </li> <li> - <strong>From</strong>: {{.Message.Envelope.From | formataddrlist}} + <strong>From</strong>: {{template "addr-list" .Message.Envelope.From}} </li> <li> - <strong>To</strong>: {{.Message.Envelope.To | formataddrlist}} + <strong>To</strong>: {{template "addr-list" .Message.Envelope.To}} </li> {{if .Message.Envelope.Cc}} <li> - <strong>Cc</strong>: {{.Message.Envelope.Cc | formataddrlist}} + <strong>Cc</strong>: {{template "addr-list" .Message.Envelope.Cc}} </li> {{end}} {{if .Message.Envelope.Bcc}} <li> - <strong>Bcc</strong>: {{.Message.Envelope.Bcc | formataddrlist}} + <strong>Bcc</strong>: {{template "addr-list" .Message.Envelope.Bcc}} </li> {{end}} </ul> diff --git a/plugins/base/routes.go b/plugins/base/routes.go index 84126d3..d73dfea 100644 --- a/plugins/base/routes.go +++ b/plugins/base/routes.go @@ -263,6 +263,11 @@ func handleCompose(ectx echo.Context) error { msg.From = ctx.Session.Username() } + msg.To = strings.Split(ctx.QueryParam("to"), ",") + msg.Subject = ctx.QueryParam("subject") + msg.Text = ctx.QueryParam("body") + msg.InReplyTo = ctx.QueryParam("in-reply-to") + if ctx.Request().Method == http.MethodGet && ctx.Param("uid") != "" { // This is a reply mboxName, uid, err := parseMboxAndUid(ctx.Param("mbox"), ctx.Param("uid")) diff --git a/plugins/base/template.go b/plugins/base/template.go index 714ca3c..d867ff3 100644 --- a/plugins/base/template.go +++ b/plugins/base/template.go @@ -3,7 +3,6 @@ package koushinbase import ( "html/template" "net/url" - "strings" "time" "github.com/emersion/go-imap" @@ -16,13 +15,6 @@ var templateFuncs = template.FuncMap{ "pathescape": func(s string) string { return url.PathEscape(s) }, - "formataddrlist": func(addrs []*imap.Address) string { - l := make([]string, len(addrs)) - for i, addr := range addrs { - l[i] = addr.PersonalName + " <" + addr.Address() + ">" - } - return strings.Join(l, ", ") - }, "formatdate": func(t time.Time) string { return t.Format("Mon Jan 02 15:04") }, |