1
0

feat: embed the vikunja logo as inline attachment

This commit is contained in:
kolaente
2022-06-19 16:21:11 +02:00
committed by Gitea
parent 30e0e98f77
commit f4f8450d16
8 changed files with 22 additions and 7 deletions

View File

@ -20,6 +20,7 @@ import (
"code.vikunja.io/api/pkg/config"
"code.vikunja.io/api/pkg/log"
"code.vikunja.io/api/pkg/version"
"io"
"github.com/wneessen/go-mail"
)
@ -34,6 +35,7 @@ type Opts struct {
ContentType ContentType
Boundary string
Headers []*header
Embeds map[string]io.Reader
}
// ContentType represents mail content types
@ -78,10 +80,15 @@ func getMessage(opts *Opts) *mail.Msg {
_ = m.From(opts.From)
_ = m.To(opts.To)
m.Subject(opts.Subject)
for _, h := range opts.Headers {
m.SetHeader(h.Field, h.Content)
}
for name, content := range opts.Embeds {
m.EmbedReader(name, content)
}
switch opts.ContentType {
case ContentTypePlain:
m.SetBodyString("text/plain", opts.Message)