jlelse
/
MailyGo
Archived
1
Fork 0

Sort displayed values

This commit is contained in:
Jan-Lukas Else 2020-03-15 17:15:08 +01:00
parent b1f828e598
commit 80b557f884
1 changed files with 9 additions and 2 deletions

11
mail.go
View File

@ -4,6 +4,7 @@ import (
"bytes"
"fmt"
"net/smtp"
"sort"
"strconv"
"strings"
"time"
@ -29,10 +30,16 @@ func buildMessage(recipient string, date time.Time, values FormValues) string {
_, _ = fmt.Fprintf(&msgBuffer, "Subject: New submission on %s", findFormName(values))
_, _ = fmt.Fprintln(&msgBuffer)
_, _ = fmt.Fprintln(&msgBuffer)
for key, value := range removeMetaValues(values) {
bodyValues := removeMetaValues(values)
var keys []string
for key, _ := range bodyValues {
keys = append(keys, key)
}
sort.Strings(keys)
for _, key := range keys {
_, _ = fmt.Fprint(&msgBuffer, key)
_, _ = fmt.Fprint(&msgBuffer, ": ")
_, _ = fmt.Fprintln(&msgBuffer, strings.Join(value, ", "))
_, _ = fmt.Fprintln(&msgBuffer, strings.Join(bodyValues[key], ", "))
}
return msgBuffer.String()
}