Don't export raw email HTML

This commit is contained in:
Taras Kushnir
2025-08-15 20:07:00 +03:00
parent ce0c50fcf4
commit 4ae499b2ed
5 changed files with 14 additions and 14 deletions
+4 -4
View File
@@ -14,12 +14,12 @@ type APIKeyExpirationContext struct {
}
var (
APIKeyExirationTemplate = common.NewEmailTemplate("apikey-expiration", APIKeyExpirationHTMLTemplate)
APIKeyExpiredTemplate = common.NewEmailTemplate("apikey-expired", APIKeyExpiredHTMLTemplate)
APIKeyExirationTemplate = common.NewEmailTemplate("apikey-expiration", apiKeyExpirationHTMLTemplate)
APIKeyExpiredTemplate = common.NewEmailTemplate("apikey-expired", apiKeyExpiredHTMLTemplate)
)
const (
APIKeyExpirationHTMLTemplate = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
apiKeyExpirationHTMLTemplate = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="ltr" lang="en">
<head>
<link rel="preload" as="image" href="{{.CDNURL}}/portal/img/pc-logo-dark.png" />
@@ -63,7 +63,7 @@ const (
</body>
</html>`
APIKeyExpiredHTMLTemplate = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
apiKeyExpiredHTMLTemplate = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="ltr" lang="en">
<head>
<link rel="preload" as="image" href="{{.CDNURL}}/portal/img/pc-logo-dark.png" />
+2 -2
View File
@@ -33,9 +33,9 @@ func NewPortalMailer(cdnURL, portalURL string, mailer Sender, cfg common.ConfigS
ReplyToEmail: cfg.Get(common.ReplyToEmailKey),
CDNURL: strings.TrimSuffix(cdnURL, "/"),
PortalURL: strings.TrimSuffix(portalURL, "/"),
twofactorHTMLTemplate: template.Must(template.New("HtmlBody").Parse(TwoFactorHTMLTemplate)),
twofactorHTMLTemplate: template.Must(template.New("HtmlBody").Parse(twoFactorHTMLTemplate)),
twofactorTextTemplate: template.Must(template.New("TextBody").Parse(twoFactorTextTemplate)),
welcomeHTMLTemplate: template.Must(template.New("HtmlBody").Parse(WelcomeHTMLTemplate)),
welcomeHTMLTemplate: template.Must(template.New("HtmlBody").Parse(welcomeHTMLTemplate)),
welcomeTextTemplate: template.Must(template.New("TextBody").Parse(welcomeTextTemplate)),
}
}
+4 -4
View File
@@ -12,12 +12,12 @@ func TestCanBeHTML(t *testing.T) {
text string
expected bool
}{
{WelcomeHTMLTemplate, true},
{TwoFactorHTMLTemplate, true},
{welcomeHTMLTemplate, true},
{twoFactorHTMLTemplate, true},
{welcomeTextTemplate, false},
{twoFactorTextTemplate, false},
{APIKeyExpirationHTMLTemplate, true},
{APIKeyExpiredHTMLTemplate, true},
{apiKeyExpirationHTMLTemplate, true},
{apiKeyExpiredHTMLTemplate, true},
}
for i, tc := range testCases {
+2 -2
View File
@@ -3,11 +3,11 @@ package email
import "github.com/PrivateCaptcha/PrivateCaptcha/pkg/common"
var (
TwoFactorEmailTemplate = common.NewEmailTemplate("twofactor", TwoFactorHTMLTemplate)
TwoFactorEmailTemplate = common.NewEmailTemplate("twofactor", twoFactorHTMLTemplate)
)
const (
TwoFactorHTMLTemplate = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
twoFactorHTMLTemplate = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="ltr" lang="en">
<head>
<link rel="preload" as="image" href="{{.CDNURL}}/portal/img/pc-logo-light.png" />
+2 -2
View File
@@ -3,11 +3,11 @@ package email
import "github.com/PrivateCaptcha/PrivateCaptcha/pkg/common"
var (
WelcomeEmailTemplate = common.NewEmailTemplate("welcome", WelcomeHTMLTemplate)
WelcomeEmailTemplate = common.NewEmailTemplate("welcome", welcomeHTMLTemplate)
)
const (
WelcomeHTMLTemplate = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
welcomeHTMLTemplate = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="ltr" lang="en">
<head>
<link rel="preload" as="image" href="{{.CDNURL}}/portal/img/pc-logo-dark.png" />