Skip to content

Commit

Permalink
mail: update year in template
Browse files Browse the repository at this point in the history
  • Loading branch information
wuhan005 committed Dec 12, 2023
1 parent 850d6a2 commit 6951a0b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions internal/mail/mail.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"embed"
"fmt"
"html/template"
"time"

"github.com/pkg/errors"
"gopkg.in/gomail.v2"
Expand Down Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion templates/mail/new-answer.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
我们向您发送这封邮件来告诉您在 NekoBox 的活动状态,若您未曾使用过 NekoBox,请忽略本邮件。
</div>
<div style="direction: ltr;">
2022 NekoBox
{{ .year }} NekoBox
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/mail/new-question.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
我们向您发送这封邮件来告诉您账号的状态,若您未曾在 NekoBox 注册过账号,请忽略本邮件。
</div>
<div style="direction: ltr;">
2022 NekoBox
{{ .year }} NekoBox
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/mail/password-recovery.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
我们向您发送这封邮件来告诉您账号的状态,若您未曾在 NekoBox 注册过账号,请忽略本邮件。
</div>
<div style="direction: ltr;">
2022 NekoBox
{{ .year }} NekoBox
</div>
</div>
</div>
Expand Down

0 comments on commit 6951a0b

Please sign in to comment.