@ -26,7 +26,6 @@ import (
"code.gitea.io/gitea/modules/markup"
"code.gitea.io/gitea/modules/markup"
"code.gitea.io/gitea/modules/markup/markdown"
"code.gitea.io/gitea/modules/markup/markdown"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/templates"
"code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/translation"
"code.gitea.io/gitea/modules/translation"
incoming_payload "code.gitea.io/gitea/services/mailer/incoming/payload"
incoming_payload "code.gitea.io/gitea/services/mailer/incoming/payload"
@ -68,15 +67,12 @@ func SendTestMail(email string) error {
func sendUserMail ( language string , u * user_model . User , tpl base . TplName , code , subject , info string ) {
func sendUserMail ( language string , u * user_model . User , tpl base . TplName , code , subject , info string ) {
locale := translation . NewLocale ( language )
locale := translation . NewLocale ( language )
data := map [ string ] any {
data := map [ string ] any {
"locale" : locale ,
"DisplayName" : u . DisplayName ( ) ,
"DisplayName" : u . DisplayName ( ) ,
"ActiveCodeLives" : timeutil . MinutesToFriendly ( setting . Service . ActiveCodeLives , locale ) ,
"ActiveCodeLives" : timeutil . MinutesToFriendly ( setting . Service . ActiveCodeLives , locale ) ,
"ResetPwdCodeLives" : timeutil . MinutesToFriendly ( setting . Service . ResetPwdCodeLives , locale ) ,
"ResetPwdCodeLives" : timeutil . MinutesToFriendly ( setting . Service . ResetPwdCodeLives , locale ) ,
"Code" : code ,
"Code" : code ,
"Language" : locale . Language ( ) ,
"Language" : locale . Language ( ) ,
// helper
"locale" : locale ,
"Str2html" : templates . Str2html ,
"DotEscape" : templates . DotEscape ,
}
}
var content bytes . Buffer
var content bytes . Buffer
@ -119,15 +115,12 @@ func SendActivateEmailMail(u *user_model.User, email *user_model.EmailAddress) {
}
}
locale := translation . NewLocale ( u . Language )
locale := translation . NewLocale ( u . Language )
data := map [ string ] any {
data := map [ string ] any {
"locale" : locale ,
"DisplayName" : u . DisplayName ( ) ,
"DisplayName" : u . DisplayName ( ) ,
"ActiveCodeLives" : timeutil . MinutesToFriendly ( setting . Service . ActiveCodeLives , locale ) ,
"ActiveCodeLives" : timeutil . MinutesToFriendly ( setting . Service . ActiveCodeLives , locale ) ,
"Code" : u . GenerateEmailActivateCode ( email . Email ) ,
"Code" : u . GenerateEmailActivateCode ( email . Email ) ,
"Email" : email . Email ,
"Email" : email . Email ,
"Language" : locale . Language ( ) ,
"Language" : locale . Language ( ) ,
// helper
"locale" : locale ,
"Str2html" : templates . Str2html ,
"DotEscape" : templates . DotEscape ,
}
}
var content bytes . Buffer
var content bytes . Buffer
@ -152,13 +145,10 @@ func SendRegisterNotifyMail(u *user_model.User) {
locale := translation . NewLocale ( u . Language )
locale := translation . NewLocale ( u . Language )
data := map [ string ] any {
data := map [ string ] any {
"locale" : locale ,
"DisplayName" : u . DisplayName ( ) ,
"DisplayName" : u . DisplayName ( ) ,
"Username" : u . Name ,
"Username" : u . Name ,
"Language" : locale . Language ( ) ,
"Language" : locale . Language ( ) ,
// helper
"locale" : locale ,
"Str2html" : templates . Str2html ,
"DotEscape" : templates . DotEscape ,
}
}
var content bytes . Buffer
var content bytes . Buffer
@ -185,14 +175,11 @@ func SendCollaboratorMail(u, doer *user_model.User, repo *repo_model.Repository)
subject := locale . Tr ( "mail.repo.collaborator.added.subject" , doer . DisplayName ( ) , repoName )
subject := locale . Tr ( "mail.repo.collaborator.added.subject" , doer . DisplayName ( ) , repoName )
data := map [ string ] any {
data := map [ string ] any {
"locale" : locale ,
"Subject" : subject ,
"Subject" : subject ,
"RepoName" : repoName ,
"RepoName" : repoName ,
"Link" : repo . HTMLURL ( ) ,
"Link" : repo . HTMLURL ( ) ,
"Language" : locale . Language ( ) ,
"Language" : locale . Language ( ) ,
// helper
"locale" : locale ,
"Str2html" : templates . Str2html ,
"DotEscape" : templates . DotEscape ,
}
}
var content bytes . Buffer
var content bytes . Buffer
@ -259,6 +246,7 @@ func composeIssueCommentMessages(ctx *mailCommentContext, lang string, recipient
locale := translation . NewLocale ( lang )
locale := translation . NewLocale ( lang )
mailMeta := map [ string ] any {
mailMeta := map [ string ] any {
"locale" : locale ,
"FallbackSubject" : fallback ,
"FallbackSubject" : fallback ,
"Body" : body ,
"Body" : body ,
"Link" : link ,
"Link" : link ,
@ -275,10 +263,6 @@ func composeIssueCommentMessages(ctx *mailCommentContext, lang string, recipient
"ReviewComments" : reviewComments ,
"ReviewComments" : reviewComments ,
"Language" : locale . Language ( ) ,
"Language" : locale . Language ( ) ,
"CanReply" : setting . IncomingEmail . Enabled && commentType != issues_model . CommentTypePullRequestPush ,
"CanReply" : setting . IncomingEmail . Enabled && commentType != issues_model . CommentTypePullRequestPush ,
// helper
"locale" : locale ,
"Str2html" : templates . Str2html ,
"DotEscape" : templates . DotEscape ,
}
}
var mailSubject bytes . Buffer
var mailSubject bytes . Buffer
@ -469,7 +453,7 @@ func SendIssueAssignedMail(ctx context.Context, issue *issues_model.Issue, doer
if err != nil {
if err != nil {
return err
return err
}
}
SendAsyncs ( msgs )
SendAsync ( msgs ... )
}
}
return nil
return nil
}
}