Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some more e-mail notification fixes #9596

Merged
merged 2 commits into from
Jan 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion modules/notification/mail/mail.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func (m *mailNotifier) NotifyNewIssue(issue *models.Issue) {

func (m *mailNotifier) NotifyIssueChangeStatus(doer *models.User, issue *models.Issue, actionComment *models.Comment, isClosed bool) {
var actionType models.ActionType
issue.Content = ""
if issue.IsPull {
if isClosed {
actionType = models.ActionClosePullRequest
Expand Down Expand Up @@ -105,7 +106,7 @@ func (m *mailNotifier) NotifyMergePullRequest(pr *models.PullRequest, doer *mode
log.Error("pr.LoadIssue: %v", err)
return
}

pr.Issue.Content = ""
if err := mailer.MailParticipants(pr.Issue, doer, models.ActionMergePullRequest); err != nil {
log.Error("MailParticipants: %v", err)
}
Expand Down
10 changes: 6 additions & 4 deletions services/mailer/mail.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ func composeIssueCommentMessages(ctx *mailCommentContext, tos []string, fromMent

commentType := models.CommentTypeComment
if ctx.Comment != nil {
prefix = "Re: "
commentType = ctx.Comment.Type
link = ctx.Issue.HTMLURL() + "#" + ctx.Comment.HashTag()
} else {
Expand All @@ -189,13 +188,16 @@ func composeIssueCommentMessages(ctx *mailCommentContext, tos []string, fromMent
reviewType = ctx.Comment.Review.Type
}

fallback = prefix + fallbackMailSubject(ctx.Issue)

// This is the body of the new issue or comment, not the mail body
body := string(markup.RenderByType(markdown.MarkupName, []byte(ctx.Content), ctx.Issue.Repo.HTMLURL(), ctx.Issue.Repo.ComposeMetas()))

actType, actName, tplName := actionToTemplate(ctx.Issue, ctx.ActionType, commentType, reviewType)

if actName != "new" {
prefix = "Re: "
}
fallback = prefix + fallbackMailSubject(ctx.Issue)

if ctx.Comment != nil && ctx.Comment.Review != nil {
reviewComments = make([]*models.Comment, 0, 10)
for _, lines := range ctx.Comment.Review.CodeComments {
Expand Down Expand Up @@ -247,7 +249,7 @@ func composeIssueCommentMessages(ctx *mailCommentContext, tos []string, fromMent
msg.Info = fmt.Sprintf("Subject: %s, %s", subject, info)

// Set Message-ID on first message so replies know what to reference
if ctx.Comment == nil {
if actName == "new" {
msg.SetHeader("Message-ID", "<"+ctx.Issue.ReplyReference()+">")
} else {
msg.SetHeader("In-Reply-To", "<"+ctx.Issue.ReplyReference()+">")
Expand Down
16 changes: 10 additions & 6 deletions templates/mail/issue/assigned.tmpl
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<style>
.footer { font-size:small; color:#666;}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{{.Subject}}</title>
</head>

<body>
<p>@{{.Doer.Name}} assigned you to the {{if .IsPull}}pull request{{else}}issue{{end}} <a href="{{.Link}}">#{{.Issue.Index}}</a> in repository {{.Repo}}.</p>
<p>
---
<br>
<a href="{{.Link}}">View it on {{AppName}}</a>.
</p>

<div class="footer">
<p>
---
<br>
<a href="{{.Link}}">View it on {{AppName}}</a>.
</p>
</div>
</body>
</html>
15 changes: 11 additions & 4 deletions templates/mail/issue/default.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{{.Subject}}</title>
{{if .ReviewComments}}

<style>
.review { padding-left: 1em; margin: 1em 0; }
.review > pre { padding: 1em; border-left: 1px solid grey; }
.footer { font-size:small; color:#666;}
{{if .ReviewComments}}
.review { padding-left: 1em; margin: 1em 0; }
.review > pre { padding: 1em; border-left: 1px solid grey; }
{{end}}
</style>
{{end}}

</head>

<body>
Expand All @@ -18,6 +21,8 @@
Closed #{{.Issue.Index}}.
{{else if eq .ActionName "reopen"}}
Reopened #{{.Issue.Index}}.
{{else if eq .ActionName "merge"}}
Merged #{{.Issue.Index}} into {{.Issue.PullRequest.BaseBranch}}.
{{else if eq .ActionName "approve"}}
<b>@{{.Doer.Name}}</b> approved this pull request.
{{else if eq .ActionName "reject"}}
Expand All @@ -42,10 +47,12 @@
</div>
{{end -}}
</p>
<div class="footer">
<p>
---
<br>
<a href="{{.Link}}">View it on {{AppName}}</a>.
</p>
</div>
</body>
</html>
15 changes: 10 additions & 5 deletions templates/mail/notify/collaborator.tmpl
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<style>
.footer { font-size:small; color:#666;}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{{.Subject}}</title>
</head>

<body>
<p>You have been added as a collaborator of repository: <code>{{.RepoName}}</code></p>
<p>
---
<br>
<a href="{{.Link}}">View it on Gitea</a>.
</p>
<div class="footer">
<p>
---
<br>
<a href="{{.Link}}">View it on {{AppName}}</a>.
</p>
</div>
</body>
</html>