MSG-AFTER`, att1.UUID)
require.NoError(t, issues_model.UpdateIssueCols(t.Context(), issue, "content"))
diff --git a/services/mailer/mail_user.go b/services/mailer/mail_user.go
index 68df81f6a3a..867a8b2a8f4 100644
--- a/services/mailer/mail_user.go
+++ b/services/mailer/mail_user.go
@@ -7,7 +7,6 @@ import (
"bytes"
"fmt"
- repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
@@ -18,11 +17,10 @@ import (
)
const (
- mailAuthActivate templates.TplName = "auth/activate"
- mailAuthActivateEmail templates.TplName = "auth/activate_email"
- mailAuthResetPassword templates.TplName = "auth/reset_passwd"
- mailAuthRegisterNotify templates.TplName = "auth/register_notify"
- mailNotifyCollaborator templates.TplName = "notify/collaborator"
+ mailAuthActivate templates.TplName = "user/auth/activate"
+ mailAuthActivateEmail templates.TplName = "user/auth/activate_email"
+ mailAuthResetPassword templates.TplName = "user/auth/reset_passwd"
+ mailAuthRegisterNotify templates.TplName = "user/auth/register_notify"
)
// sendUserMail sends a mail to the user
@@ -128,34 +126,3 @@ func SendRegisterNotifyMail(u *user_model.User) {
SendAsync(msg)
}
-
-// SendCollaboratorMail sends mail notification to new collaborator.
-func SendCollaboratorMail(u, doer *user_model.User, repo *repo_model.Repository) {
- if setting.MailService == nil || !u.IsActive {
- // No mail service configured OR the user is inactive
- return
- }
- locale := translation.NewLocale(u.Language)
- repoName := repo.FullName()
-
- subject := locale.TrString("mail.repo.collaborator.added.subject", doer.DisplayName(), repoName)
- data := map[string]any{
- "locale": locale,
- "Subject": subject,
- "RepoName": repoName,
- "Link": repo.HTMLURL(),
- "Language": locale.Language(),
- }
-
- var content bytes.Buffer
-
- if err := LoadedTemplates().BodyTemplates.ExecuteTemplate(&content, string(mailNotifyCollaborator), data); err != nil {
- log.Error("Template: %v", err)
- return
- }
-
- msg := sender_service.NewMessage(u.EmailTo(), subject, content.String())
- msg.Info = fmt.Sprintf("UID: %d, add collaborator", u.ID)
-
- SendAsync(msg)
-}
diff --git a/services/mailer/mail_workflow_run.go b/services/mailer/mail_workflow_run.go
index 29b3abda8ee..664d1bd1654 100644
--- a/services/mailer/mail_workflow_run.go
+++ b/services/mailer/mail_workflow_run.go
@@ -8,6 +8,7 @@ import (
"context"
"fmt"
"sort"
+ "time"
actions_model "code.gitea.io/gitea/models/actions"
repo_model "code.gitea.io/gitea/models/repo"
@@ -15,18 +16,20 @@ import (
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
+ "code.gitea.io/gitea/modules/templates"
"code.gitea.io/gitea/modules/translation"
"code.gitea.io/gitea/services/convert"
sender_service "code.gitea.io/gitea/services/mailer/sender"
)
-const tplWorkflowRun = "notify/workflow_run"
+const tplWorkflowRun templates.TplName = "repo/actions/workflow_run"
type convertedWorkflowJob struct {
- HTMLURL string
- Status actions_model.Status
- Name string
- Attempt int64
+ HTMLURL string
+ Name string
+ Status actions_model.Status
+ Attempt int64
+ Duration time.Duration
}
func generateMessageIDForActionsWorkflowRunStatusEmail(repo *repo_model.Repository, run *actions_model.ActionRun) string {
@@ -34,16 +37,15 @@ func generateMessageIDForActionsWorkflowRunStatusEmail(repo *repo_model.Reposito
}
func composeAndSendActionsWorkflowRunStatusEmail(ctx context.Context, repo *repo_model.Repository, run *actions_model.ActionRun, sender *user_model.User, recipients []*user_model.User) {
- subject := "Run"
+ var subjectTrString string
switch run.Status {
case actions_model.StatusFailure:
- subject += " failed"
+ subjectTrString = "mail.repo.actions.run.failed"
case actions_model.StatusCancelled:
- subject += " cancelled"
+ subjectTrString = "mail.repo.actions.run.cancelled"
case actions_model.StatusSuccess:
- subject += " succeeded"
+ subjectTrString = "mail.repo.actions.run.succeeded"
}
- subject = fmt.Sprintf("%s: %s (%s)", subject, run.WorkflowID, base.ShortSha(run.CommitSHA))
displayName := fromDisplayName(sender)
messageID := generateMessageIDForActionsWorkflowRunStatusEmail(repo, run)
metadataHeaders := generateMetadataHeaders(repo)
@@ -74,10 +76,11 @@ func composeAndSendActionsWorkflowRunStatusEmail(ctx context.Context, repo *repo
continue
}
convertedJobs = append(convertedJobs, convertedWorkflowJob{
- HTMLURL: converted0.HTMLURL,
- Name: converted0.Name,
- Status: job.Status,
- Attempt: converted0.RunAttempt,
+ HTMLURL: converted0.HTMLURL,
+ Name: converted0.Name,
+ Status: job.Status,
+ Attempt: converted0.RunAttempt,
+ Duration: job.Duration(),
})
}
@@ -87,27 +90,28 @@ func composeAndSendActionsWorkflowRunStatusEmail(ctx context.Context, repo *repo
}
for lang, tos := range langMap {
locale := translation.NewLocale(lang)
- var runStatusText string
+ var runStatusTrString string
switch run.Status {
case actions_model.StatusSuccess:
- runStatusText = "All jobs have succeeded"
+ runStatusTrString = "mail.repo.actions.jobs.all_succeeded"
case actions_model.StatusFailure:
- runStatusText = "All jobs have failed"
+ runStatusTrString = "mail.repo.actions.jobs.all_failed"
for _, job := range jobs {
if !job.Status.IsFailure() {
- runStatusText = "Some jobs were not successful"
+ runStatusTrString = "mail.repo.actions.jobs.some_not_successful"
break
}
}
case actions_model.StatusCancelled:
- runStatusText = "All jobs have been cancelled"
+ runStatusTrString = "mail.repo.actions.jobs.all_cancelled"
}
+ subject := fmt.Sprintf("%s: %s (%s)", locale.TrString(subjectTrString), run.WorkflowID, base.ShortSha(run.CommitSHA))
var mailBody bytes.Buffer
- if err := LoadedTemplates().BodyTemplates.ExecuteTemplate(&mailBody, tplWorkflowRun, map[string]any{
+ if err := LoadedTemplates().BodyTemplates.ExecuteTemplate(&mailBody, string(tplWorkflowRun), map[string]any{
"Subject": subject,
"Repo": repo,
"Run": run,
- "RunStatusText": runStatusText,
+ "RunStatusText": locale.TrString(runStatusTrString),
"Jobs": convertedJobs,
"locale": locale,
}); err != nil {
diff --git a/templates/mail/footer_gitea.tmpl b/templates/mail/footer_gitea.tmpl
new file mode 100644
index 00000000000..6ec5bee0164
--- /dev/null
+++ b/templates/mail/footer_gitea.tmpl
@@ -0,0 +1,6 @@
+
+
+
+© {{AppName}}
+
+
diff --git a/templates/mail/footer_view_on_gitea.tmpl b/templates/mail/footer_view_on_gitea.tmpl
new file mode 100644
index 00000000000..3625a58e5d8
--- /dev/null
+++ b/templates/mail/footer_view_on_gitea.tmpl
@@ -0,0 +1,12 @@
+
+
+
+
+
+
diff --git a/templates/mail/org/team_invite.devtest.yml b/templates/mail/org/team_invite.devtest.yml
new file mode 100644
index 00000000000..dc51a74d641
--- /dev/null
+++ b/templates/mail/org/team_invite.devtest.yml
@@ -0,0 +1,13 @@
+Inviter:
+ DisplayName: Inviter Display Name
+
+Team:
+ Name: Team name
+
+Organization:
+ DisplayName: Organization Display Name
+
+InviteURL: http://localhost/org/team/invite
+
+Invite:
+ Email: invited@example.com
diff --git a/templates/mail/team_invite.tmpl b/templates/mail/org/team_invite.tmpl
similarity index 86%
rename from templates/mail/team_invite.tmpl
rename to templates/mail/org/team_invite.tmpl
index cb0c0c0a50b..29dc9a37ae5 100644
--- a/templates/mail/team_invite.tmpl
+++ b/templates/mail/org/team_invite.tmpl
@@ -10,6 +10,6 @@
{{.locale.Tr "mail.link_not_working_do_paste"}}
{{.locale.Tr "mail.team_invite.text_3" .Invite.Email}}
- © {{AppName}}
+ {{template "footer_gitea"}}