Skip to content

Commit

Permalink
finish
Browse files Browse the repository at this point in the history
  • Loading branch information
6543 committed Jun 20, 2021
1 parent 813e757 commit 7157633
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
6 changes: 0 additions & 6 deletions services/mailer/mail.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ func sendUserMail(language string, u *models.User, tpl base.TplName, code, subje

var content bytes.Buffer

// TODO: i18n templates?
if err := bodyTemplates.ExecuteTemplate(&content, string(tpl), data); err != nil {
log.Error("Template: %v", err)
return
Expand Down Expand Up @@ -115,7 +114,6 @@ func SendActivateEmailMail(u *models.User, email *models.EmailAddress) {

var content bytes.Buffer

// TODO: i18n templates?
if err := bodyTemplates.ExecuteTemplate(&content, string(mailAuthActivateEmail), data); err != nil {
log.Error("Template: %v", err)
return
Expand All @@ -142,7 +140,6 @@ func SendRegisterNotifyMail(u *models.User) {

var content bytes.Buffer

// TODO: i18n templates?
if err := bodyTemplates.ExecuteTemplate(&content, string(mailAuthRegisterNotify), data); err != nil {
log.Error("Template: %v", err)
return
Expand Down Expand Up @@ -172,7 +169,6 @@ func SendCollaboratorMail(u, doer *models.User, repo *models.Repository) {

var content bytes.Buffer

// TODO: i18n templates?
if err := bodyTemplates.ExecuteTemplate(&content, string(mailNotifyCollaborator), data); err != nil {
log.Error("Template: %v", err)
return
Expand Down Expand Up @@ -255,7 +251,6 @@ func composeIssueCommentMessages(ctx *mailCommentContext, lang string, recipient
}

var mailSubject bytes.Buffer
// TODO: i18n templates?
if err := subjectTemplates.ExecuteTemplate(&mailSubject, string(tplName), mailMeta); err == nil {
subject = sanitizeSubject(mailSubject.String())
if subject == "" {
Expand All @@ -271,7 +266,6 @@ func composeIssueCommentMessages(ctx *mailCommentContext, lang string, recipient

var mailBody bytes.Buffer

// TODO: i18n templates?
if err := bodyTemplates.ExecuteTemplate(&mailBody, string(tplName), mailMeta); err != nil {
log.Error("ExecuteTemplate [%s]: %v", string(tplName)+"/body", err)
}
Expand Down
6 changes: 4 additions & 2 deletions services/mailer/mail_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"code.gitea.io/gitea/modules/markup"
"code.gitea.io/gitea/modules/markup/markdown"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/templates"
"code.gitea.io/gitea/modules/translation"
)

Expand Down Expand Up @@ -63,13 +64,14 @@ func mailNewRelease(lang string, tos []string, rel *models.Release) {
mailMeta := map[string]interface{}{
"Release": rel,
"Subject": subject,
"i18n": locale,
"Language": locale.Language(),
// helper
"i18n": locale,
"Str2html": templates.Str2html,
}

var mailBody bytes.Buffer

// TODO: i18n templates?
if err := bodyTemplates.ExecuteTemplate(&mailBody, string(tplNewReleaseMail), mailMeta); err != nil {
log.Error("ExecuteTemplate [%s]: %v", string(tplNewReleaseMail)+"/body", err)
return
Expand Down
6 changes: 4 additions & 2 deletions services/mailer/mail_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"

"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/templates"
"code.gitea.io/gitea/modules/translation"
)

Expand Down Expand Up @@ -57,12 +58,13 @@ func sendRepoTransferNotifyMailPerLang(lang string, newOwner, doer *models.User,
"Repo": repo.FullName(),
"Link": repo.HTMLURL(),
"Subject": subject,
"i18n": locale,
"Language": locale.Language(),
"Destination": destination,
// helper
"i18n": locale,
"Str2html": templates.Str2html,
}

// TODO: i18n templates?
if err := bodyTemplates.ExecuteTemplate(&content, string(mailRepoTransferNotify), data); err != nil {
return err
}
Expand Down

0 comments on commit 7157633

Please sign in to comment.