From df63ab8d5e97bca3ef930ed7ae4f92a61fcd8144 Mon Sep 17 00:00:00 2001 From: Evan Chen Date: Sat, 25 Dec 2021 03:31:53 +0800 Subject: [PATCH] update --- email/base.gohtml | 17 ++++++++++++++++- email/email.go | 9 +++++---- email/engine.go | 4 ++++ email/service.go | 1 + 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/email/base.gohtml b/email/base.gohtml index f30654c..c5d2968 100644 --- a/email/base.gohtml +++ b/email/base.gohtml @@ -347,7 +347,22 @@
{{ if .Sender }}{{.Sender}}{{else}}{{.App.Name}}{{end}}

- + {{ with .Actions }} + + + {{ range $action := . }} + {{if $action.Button.Text}} + + + + {{ end }} + {{ end }} + +
+

{{$.App.TroubleText | replace "{ACTION}" $action.Button.Text}}

+

{{ $action.Button.Link }}

+
+ {{ end }} diff --git a/email/email.go b/email/email.go index 7ddd31a..0037f7e 100644 --- a/email/email.go +++ b/email/email.go @@ -15,10 +15,11 @@ func init() { } type App struct { - Name string - Link string - Logo string - Copyright string + Name string + Link string + Logo string + Copyright string + TroubleText string } type Button struct { diff --git a/email/engine.go b/email/engine.go index 9703fae..a061efa 100644 --- a/email/engine.go +++ b/email/engine.go @@ -4,6 +4,7 @@ import ( "bytes" _ "embed" "html/template" + "strings" "github.com/vanng822/go-premailer/premailer" "github.com/yuin/goldmark" @@ -29,6 +30,9 @@ func init() { "mul": func(a, b int) int { return a * b }, + "replace": func(from, to, input string) string { + return strings.Replace(input, from, to, -1) + }, }).Parse(mailTmpl)) } diff --git a/email/service.go b/email/service.go index 3770d84..fd12841 100644 --- a/email/service.go +++ b/email/service.go @@ -37,5 +37,6 @@ func setupDefault() { time.Now().Year(), app.Name) app.Link = "https://kumoly.io" app.Logo = "http://www.duchess-france.org/wp-content/uploads/2016/01/gopher.png" + app.TroubleText = "If you’re having trouble with the button '{ACTION}', copy and paste the URL below into your web browser." dial = gomail.NewDialer("mail.kumoly.io", 587, "test@kumoly.io", "test") }