Skip to content

Fix mail template error #29410

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions modules/templates/mailer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm of the opinion that behaviour differences between RUN_MODE should be kept minimal. Is it warranted here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I think it should also "Fatal" (just like web page HTML templates)

But the old code just reports the error message and continues. So I chose to keep the old behavior at the moment.

So I think it is warranted that "the behavior is the same as the old code and the change is minimal", but it doesn't warrant that "the behavior is the same for production/dev"

Feel free to change the behavior.

}
}

Expand Down
2 changes: 1 addition & 1 deletion templates/mail/notify/repo_transfer.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>{{.Subject}}</title>
</head>

{{$url := HTMLFormat "<a href='%[1]s'>%[2]s</a>" .Link .Repo)}}
{{$url := HTMLFormat "<a href='%[1]s'>%[2]s</a>" .Link .Repo}}
<body>
<p>{{.Subject}}.
{{.locale.Tr "mail.repo.transfer.body" $url}}
Expand Down