Changed email subject template from HTML to text. Fixes #785.

This commit is contained in:
Kailash Nadh 2022-05-03 10:41:46 +05:30
parent 75190d9854
commit 89eca5f14b
2 changed files with 7 additions and 2 deletions

View file

@ -436,9 +436,11 @@ func (m *Manager) TemplateFuncs(c *models.Campaign) template.FuncMap {
return template.HTML(safeHTML) return template.HTML(safeHTML)
}, },
} }
for k, v := range sprig.GenericFuncMap() { for k, v := range sprig.GenericFuncMap() {
f[k] = v f[k] = v
} }
return f return f
} }

View file

@ -9,6 +9,7 @@ import (
"html/template" "html/template"
"regexp" "regexp"
"strings" "strings"
txttpl "text/template"
"time" "time"
"github.com/jmoiron/sqlx" "github.com/jmoiron/sqlx"
@ -218,7 +219,7 @@ type Campaign struct {
// TemplateBody is joined in from templates by the next-campaigns query. // TemplateBody is joined in from templates by the next-campaigns query.
TemplateBody string `db:"template_body" json:"-"` TemplateBody string `db:"template_body" json:"-"`
Tpl *template.Template `json:"-"` Tpl *template.Template `json:"-"`
SubjectTpl *template.Template `json:"-"` SubjectTpl *txttpl.Template `json:"-"`
AltBodyTpl *template.Template `json:"-"` AltBodyTpl *template.Template `json:"-"`
// Pseudofield for getting the total number of subscribers // Pseudofield for getting the total number of subscribers
@ -436,7 +437,9 @@ func (c *Campaign) CompileTemplate(f template.FuncMap) error {
for _, r := range regTplFuncs { for _, r := range regTplFuncs {
subj = r.regExp.ReplaceAllString(subj, r.replace) subj = r.regExp.ReplaceAllString(subj, r.replace)
} }
subjTpl, err := template.New(ContentTpl).Funcs(f).Parse(subj)
var txtFuncs map[string]interface{} = f
subjTpl, err := txttpl.New(ContentTpl).Funcs(txtFuncs).Parse(subj)
if err != nil { if err != nil {
return fmt.Errorf("error compiling subject: %v", err) return fmt.Errorf("error compiling subject: %v", err)
} }