1
0

feat: use embed fs directly to embed the logo in mails

This commit is contained in:
kolaente
2022-07-07 15:54:38 +02:00
parent 25ffa1bc2e
commit 73c4c399e5
4 changed files with 16 additions and 5 deletions

View File

@ -17,6 +17,7 @@
package mail
import (
"embed"
"io"
"code.vikunja.io/api/pkg/config"
@ -37,6 +38,7 @@ type Opts struct {
Boundary string
Headers []*header
Embeds map[string]io.Reader
EmbedFS map[string]*embed.FS
}
// ContentType represents mail content types
@ -90,6 +92,13 @@ func getMessage(opts *Opts) *mail.Msg {
m.EmbedReader(name, content)
}
for name, fs := range opts.EmbedFS {
err := m.EmbedFromEmbedFS(name, fs)
if err != nil {
log.Errorf("Error embedding %s via embed.FS into mail: %v", err)
}
}
switch opts.ContentType {
case ContentTypePlain:
m.SetBodyString("text/plain", opts.Message)