diff options
Diffstat (limited to 'services')
-rw-r--r-- | services/mailer/mail.go | 27 | ||||
-rw-r--r-- | services/mailer/mail_release.go | 6 | ||||
-rw-r--r-- | services/mailer/mail_repo.go | 6 |
3 files changed, 24 insertions, 15 deletions
diff --git a/services/mailer/mail.go b/services/mailer/mail.go index fdc070e4be..7494d04f2b 100644 --- a/services/mailer/mail.go +++ b/services/mailer/mail.go @@ -22,6 +22,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/timeutil" "code.gitea.io/gitea/modules/translation" @@ -67,13 +68,14 @@ func sendUserMail(language string, u *models.User, tpl base.TplName, code, subje "ActiveCodeLives": timeutil.MinutesToFriendly(setting.Service.ActiveCodeLives, language), "ResetPwdCodeLives": timeutil.MinutesToFriendly(setting.Service.ResetPwdCodeLives, language), "Code": code, - "i18n": locale, "Language": locale.Language(), + // helper + "i18n": locale, + "Str2html": templates.Str2html, } var content bytes.Buffer - // TODO: i18n templates? if err := bodyTemplates.ExecuteTemplate(&content, string(tpl), data); err != nil { log.Error("Template: %v", err) return @@ -104,13 +106,14 @@ func SendActivateEmailMail(u *models.User, email *models.EmailAddress) { "ActiveCodeLives": timeutil.MinutesToFriendly(setting.Service.ActiveCodeLives, locale.Language()), "Code": u.GenerateEmailActivateCode(email.Email), "Email": email.Email, - "i18n": locale, "Language": locale.Language(), + // helper + "i18n": locale, + "Str2html": templates.Str2html, } var content bytes.Buffer - // TODO: i18n templates? if err := bodyTemplates.ExecuteTemplate(&content, string(mailAuthActivateEmail), data); err != nil { log.Error("Template: %v", err) return @@ -129,13 +132,14 @@ func SendRegisterNotifyMail(u *models.User) { data := map[string]interface{}{ "DisplayName": u.DisplayName(), "Username": u.Name, - "i18n": locale, "Language": locale.Language(), + // helper + "i18n": locale, + "Str2html": templates.Str2html, } var content bytes.Buffer - // TODO: i18n templates? if err := bodyTemplates.ExecuteTemplate(&content, string(mailAuthRegisterNotify), data); err != nil { log.Error("Template: %v", err) return @@ -157,13 +161,14 @@ func SendCollaboratorMail(u, doer *models.User, repo *models.Repository) { "Subject": subject, "RepoName": repoName, "Link": repo.HTMLURL(), - "i18n": locale, "Language": locale.Language(), + // helper + "i18n": locale, + "Str2html": templates.Str2html, } var content bytes.Buffer - // TODO: i18n templates? if err := bodyTemplates.ExecuteTemplate(&content, string(mailNotifyCollaborator), data); err != nil { log.Error("Template: %v", err) return @@ -239,12 +244,13 @@ func composeIssueCommentMessages(ctx *mailCommentContext, lang string, recipient "ActionType": actType, "ActionName": actName, "ReviewComments": reviewComments, - "i18n": locale, "Language": locale.Language(), + // helper + "i18n": locale, + "Str2html": templates.Str2html, } var mailSubject bytes.Buffer - // TODO: i18n templates? if err := subjectTemplates.ExecuteTemplate(&mailSubject, string(tplName), mailMeta); err == nil { subject = sanitizeSubject(mailSubject.String()) if subject == "" { @@ -260,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 1e12fe13ac..ff008be1d8 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 c742101ee1..5ef67b7c65 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 } |