From eb2fc1818b00b7ca6f8c21bb490a8e8be1e62f9a Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Tue, 27 Feb 2024 06:31:30 +0800 Subject: [PATCH] Fix mail template error (#29410) --- modules/templates/mailer.go | 10 ++++++++-- templates/mail/notify/repo_transfer.tmpl | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/templates/mailer.go b/modules/templates/mailer.go index 54d857a8f..04032e398 100644 --- a/modules/templates/mailer.go +++ b/modules/templates/mailer.go @@ -44,11 +44,17 @@ func buildSubjectBodyTemplate(stpl *texttmpl.Template, btpl *template.Template, } if _, err := stpl.New(name). Parse(string(subjectContent)); err != nil { - log.Warn("Failed to parse template [%s/subject]: %v", name, err) + log.Error("Failed to parse template [%s/subject]: %v", name, err) + if !setting.IsProd { + log.Fatal("Please fix the mail template error") + } } if _, err := btpl.New(name). Parse(string(bodyContent)); err != nil { - log.Warn("Failed to parse template [%s/body]: %v", name, err) + log.Error("Failed to parse template [%s/body]: %v", name, err) + if !setting.IsProd { + log.Fatal("Please fix the mail template error") + } } } diff --git a/templates/mail/notify/repo_transfer.tmpl b/templates/mail/notify/repo_transfer.tmpl index 597048ddf..8c8b27648 100644 --- a/templates/mail/notify/repo_transfer.tmpl +++ b/templates/mail/notify/repo_transfer.tmpl @@ -5,7 +5,7 @@ {{.Subject}} -{{$url := HTMLFormat "%[2]s" .Link .Repo)}} +{{$url := HTMLFormat "%[2]s" .Link .Repo}}

{{.Subject}}. {{.locale.Tr "mail.repo.transfer.body" $url}}