From 7157633ea71654e26cc4b49170896b747cd29e0c Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sun, 20 Jun 2021 14:45:03 +0200 Subject: [PATCH] finish --- services/mailer/mail.go | 6 ------ services/mailer/mail_release.go | 6 ++++-- services/mailer/mail_repo.go | 6 ++++-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/services/mailer/mail.go b/services/mailer/mail.go index b0484a9a0c8d0..cc29d78d20af1 100644 --- a/services/mailer/mail.go +++ b/services/mailer/mail.go @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 == "" { @@ -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) } diff --git a/services/mailer/mail_release.go b/services/mailer/mail_release.go index 1e12fe13acdec..ff008be1d8b80 100644 --- a/services/mailer/mail_release.go +++ b/services/mailer/mail_release.go @@ -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" ) @@ -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 diff --git a/services/mailer/mail_repo.go b/services/mailer/mail_repo.go index c742101ee1961..5ef67b7c6574a 100644 --- a/services/mailer/mail_repo.go +++ b/services/mailer/mail_repo.go @@ -9,6 +9,7 @@ import ( "fmt" "code.gitea.io/gitea/models" + "code.gitea.io/gitea/modules/templates" "code.gitea.io/gitea/modules/translation" ) @@ -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 }