From 6951a0b1dcae16999ee62a83edaf44ffbecb3a2c Mon Sep 17 00:00:00 2001 From: E99p1ant Date: Tue, 12 Dec 2023 15:51:28 +0800 Subject: [PATCH] mail: update `year` in template --- internal/mail/mail.go | 5 +++++ templates/mail/new-answer.html | 2 +- templates/mail/new-question.html | 2 +- templates/mail/password-recovery.html | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/internal/mail/mail.go b/internal/mail/mail.go index 28774c6..19e7631 100644 --- a/internal/mail/mail.go +++ b/internal/mail/mail.go @@ -10,6 +10,7 @@ import ( "embed" "fmt" "html/template" + "time" "github.com/pkg/errors" "gopkg.in/gomail.v2" @@ -49,6 +50,10 @@ func sendTemplateMail(email, title string, templateFS embed.FS, templatePath str if err != nil { return errors.Wrap(err, "parse template file") } + + // General params. + params["year"] = time.Now().Format("2006") + if err := t.Execute(&content, params); err != nil { return errors.Wrap(err, "execute template") } diff --git a/templates/mail/new-answer.html b/templates/mail/new-answer.html index 15b1e30..f4c9199 100644 --- a/templates/mail/new-answer.html +++ b/templates/mail/new-answer.html @@ -101,7 +101,7 @@ 我们向您发送这封邮件来告诉您在 NekoBox 的活动状态,若您未曾使用过 NekoBox,请忽略本邮件。
- 2022 NekoBox + {{ .year }} NekoBox
diff --git a/templates/mail/new-question.html b/templates/mail/new-question.html index 09a787a..e259db5 100644 --- a/templates/mail/new-question.html +++ b/templates/mail/new-question.html @@ -90,7 +90,7 @@ 我们向您发送这封邮件来告诉您账号的状态,若您未曾在 NekoBox 注册过账号,请忽略本邮件。
- 2022 NekoBox + {{ .year }} NekoBox
diff --git a/templates/mail/password-recovery.html b/templates/mail/password-recovery.html index 4f5161f..69ab646 100644 --- a/templates/mail/password-recovery.html +++ b/templates/mail/password-recovery.html @@ -90,7 +90,7 @@ 我们向您发送这封邮件来告诉您账号的状态,若您未曾在 NekoBox 注册过账号,请忽略本邮件。
- 2022 NekoBox + {{ .year }} NekoBox