mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-04 05:18:25 +00:00 
			
		
		
		
	Some more e-mail notification fixes (#9596)
* Some more e-mail notification fixes A few more small e-mail notification fixes/changes * Style footer of notification email to be smaller * Include text for when pull request is merged * Don't include original body of issue or PR when merging/closing by setting issue.Content to "" in these cases * Set Re: prefix and meessage-ID headers based on actName instead of checking for a comment. This fixes a bug where certain actions that didn't have a comment were setting Message-ID instead of In-Reply-To which caused some mail programs not to show those messages as they would have had the same Message-ID as a previous message. Also fixes the case where a final comment and closing message would have been displayed out of order if you didn't have a copy of the original issue/pr cretion message. * Update other template footers for consistency
This commit is contained in:
		@@ -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) {
 | 
					func (m *mailNotifier) NotifyIssueChangeStatus(doer *models.User, issue *models.Issue, actionComment *models.Comment, isClosed bool) {
 | 
				
			||||||
	var actionType models.ActionType
 | 
						var actionType models.ActionType
 | 
				
			||||||
 | 
						issue.Content = ""
 | 
				
			||||||
	if issue.IsPull {
 | 
						if issue.IsPull {
 | 
				
			||||||
		if isClosed {
 | 
							if isClosed {
 | 
				
			||||||
			actionType = models.ActionClosePullRequest
 | 
								actionType = models.ActionClosePullRequest
 | 
				
			||||||
@@ -105,7 +106,7 @@ func (m *mailNotifier) NotifyMergePullRequest(pr *models.PullRequest, doer *mode
 | 
				
			|||||||
		log.Error("pr.LoadIssue: %v", err)
 | 
							log.Error("pr.LoadIssue: %v", err)
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						pr.Issue.Content = ""
 | 
				
			||||||
	if err := mailer.MailParticipants(pr.Issue, doer, models.ActionMergePullRequest); err != nil {
 | 
						if err := mailer.MailParticipants(pr.Issue, doer, models.ActionMergePullRequest); err != nil {
 | 
				
			||||||
		log.Error("MailParticipants: %v", err)
 | 
							log.Error("MailParticipants: %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -177,7 +177,6 @@ func composeIssueCommentMessages(ctx *mailCommentContext, tos []string, fromMent
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	commentType := models.CommentTypeComment
 | 
						commentType := models.CommentTypeComment
 | 
				
			||||||
	if ctx.Comment != nil {
 | 
						if ctx.Comment != nil {
 | 
				
			||||||
		prefix = "Re: "
 | 
					 | 
				
			||||||
		commentType = ctx.Comment.Type
 | 
							commentType = ctx.Comment.Type
 | 
				
			||||||
		link = ctx.Issue.HTMLURL() + "#" + ctx.Comment.HashTag()
 | 
							link = ctx.Issue.HTMLURL() + "#" + ctx.Comment.HashTag()
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
@@ -189,13 +188,16 @@ func composeIssueCommentMessages(ctx *mailCommentContext, tos []string, fromMent
 | 
				
			|||||||
		reviewType = ctx.Comment.Review.Type
 | 
							reviewType = ctx.Comment.Review.Type
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	fallback = prefix + fallbackMailSubject(ctx.Issue)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// This is the body of the new issue or comment, not the mail body
 | 
						// 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()))
 | 
						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)
 | 
						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 {
 | 
						if ctx.Comment != nil && ctx.Comment.Review != nil {
 | 
				
			||||||
		reviewComments = make([]*models.Comment, 0, 10)
 | 
							reviewComments = make([]*models.Comment, 0, 10)
 | 
				
			||||||
		for _, lines := range ctx.Comment.Review.CodeComments {
 | 
							for _, lines := range ctx.Comment.Review.CodeComments {
 | 
				
			||||||
@@ -247,7 +249,7 @@ func composeIssueCommentMessages(ctx *mailCommentContext, tos []string, fromMent
 | 
				
			|||||||
		msg.Info = fmt.Sprintf("Subject: %s, %s", subject, info)
 | 
							msg.Info = fmt.Sprintf("Subject: %s, %s", subject, info)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// Set Message-ID on first message so replies know what to reference
 | 
							// 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()+">")
 | 
								msg.SetHeader("Message-ID", "<"+ctx.Issue.ReplyReference()+">")
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			msg.SetHeader("In-Reply-To", "<"+ctx.Issue.ReplyReference()+">")
 | 
								msg.SetHeader("In-Reply-To", "<"+ctx.Issue.ReplyReference()+">")
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,17 +1,21 @@
 | 
				
			|||||||
<!DOCTYPE html>
 | 
					<!DOCTYPE html>
 | 
				
			||||||
<html>
 | 
					<html>
 | 
				
			||||||
<head>
 | 
					<head>
 | 
				
			||||||
 | 
						<style>
 | 
				
			||||||
 | 
							.footer { font-size:small; color:#666;}
 | 
				
			||||||
 | 
						</style>
 | 
				
			||||||
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 | 
						<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 | 
				
			||||||
	<title>{{.Subject}}</title>
 | 
						<title>{{.Subject}}</title>
 | 
				
			||||||
</head>
 | 
					</head>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<body>
 | 
					<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>@{{.Doer.Name}} assigned you to the {{if .IsPull}}pull request{{else}}issue{{end}} <a href="{{.Link}}">#{{.Issue.Index}}</a> in repository {{.Repo}}.</p>
 | 
				
			||||||
    <p>
 | 
						<div class="footer">
 | 
				
			||||||
        ---
 | 
						    <p>
 | 
				
			||||||
        <br>
 | 
						        ---
 | 
				
			||||||
        <a href="{{.Link}}">View it on {{AppName}}</a>.
 | 
						        <br>
 | 
				
			||||||
    </p>
 | 
						        <a href="{{.Link}}">View it on {{AppName}}</a>.
 | 
				
			||||||
 | 
						    </p>
 | 
				
			||||||
 | 
						</div>
 | 
				
			||||||
</body>
 | 
					</body>
 | 
				
			||||||
</html>
 | 
					</html>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,12 +3,15 @@
 | 
				
			|||||||
<head>
 | 
					<head>
 | 
				
			||||||
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 | 
						<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 | 
				
			||||||
	<title>{{.Subject}}</title>
 | 
						<title>{{.Subject}}</title>
 | 
				
			||||||
	{{if .ReviewComments}}
 | 
					
 | 
				
			||||||
	<style>
 | 
						<style>
 | 
				
			||||||
		.review { padding-left: 1em; margin: 1em 0; }
 | 
							.footer { font-size:small; color:#666;}
 | 
				
			||||||
		.review > pre { padding: 1em; border-left: 1px solid grey; }
 | 
							{{if .ReviewComments}}
 | 
				
			||||||
 | 
								.review { padding-left: 1em; margin: 1em 0; }
 | 
				
			||||||
 | 
								.review > pre { padding: 1em; border-left: 1px solid grey; }
 | 
				
			||||||
 | 
							{{end}}
 | 
				
			||||||
	</style>
 | 
						</style>
 | 
				
			||||||
	{{end}}
 | 
					
 | 
				
			||||||
</head>
 | 
					</head>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<body>
 | 
					<body>
 | 
				
			||||||
@@ -18,6 +21,8 @@
 | 
				
			|||||||
			Closed #{{.Issue.Index}}.
 | 
								Closed #{{.Issue.Index}}.
 | 
				
			||||||
		{{else if eq .ActionName "reopen"}}
 | 
							{{else if eq .ActionName "reopen"}}
 | 
				
			||||||
			Reopened #{{.Issue.Index}}.
 | 
								Reopened #{{.Issue.Index}}.
 | 
				
			||||||
 | 
							{{else if eq .ActionName "merge"}}
 | 
				
			||||||
 | 
								Merged #{{.Issue.Index}} into {{.Issue.PullRequest.BaseBranch}}.
 | 
				
			||||||
		{{else if eq .ActionName "approve"}}
 | 
							{{else if eq .ActionName "approve"}}
 | 
				
			||||||
			<b>@{{.Doer.Name}}</b> approved this pull request.
 | 
								<b>@{{.Doer.Name}}</b> approved this pull request.
 | 
				
			||||||
		{{else if eq .ActionName "reject"}}
 | 
							{{else if eq .ActionName "reject"}}
 | 
				
			||||||
@@ -42,10 +47,12 @@
 | 
				
			|||||||
			</div>
 | 
								</div>
 | 
				
			||||||
		{{end -}}		
 | 
							{{end -}}		
 | 
				
			||||||
	</p>
 | 
						</p>
 | 
				
			||||||
 | 
						<div class="footer">
 | 
				
			||||||
	<p>
 | 
						<p>
 | 
				
			||||||
		---
 | 
							---
 | 
				
			||||||
		<br>
 | 
							<br>
 | 
				
			||||||
		<a href="{{.Link}}">View it on {{AppName}}</a>.
 | 
							<a href="{{.Link}}">View it on {{AppName}}</a>.
 | 
				
			||||||
	</p>
 | 
						</p>
 | 
				
			||||||
 | 
						</div>
 | 
				
			||||||
</body>
 | 
					</body>
 | 
				
			||||||
</html>
 | 
					</html>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,16 +1,21 @@
 | 
				
			|||||||
<!DOCTYPE html>
 | 
					<!DOCTYPE html>
 | 
				
			||||||
<html>
 | 
					<html>
 | 
				
			||||||
<head>
 | 
					<head>
 | 
				
			||||||
 | 
						<style>
 | 
				
			||||||
 | 
							.footer { font-size:small; color:#666;}
 | 
				
			||||||
 | 
						</style>
 | 
				
			||||||
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 | 
						<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 | 
				
			||||||
	<title>{{.Subject}}</title>
 | 
						<title>{{.Subject}}</title>
 | 
				
			||||||
</head>
 | 
					</head>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<body>
 | 
					<body>
 | 
				
			||||||
	<p>You have been added as a collaborator of repository: <code>{{.RepoName}}</code></p>
 | 
						<p>You have been added as a collaborator of repository: <code>{{.RepoName}}</code></p>
 | 
				
			||||||
	<p>
 | 
						<div class="footer">
 | 
				
			||||||
		---
 | 
						    <p>
 | 
				
			||||||
		<br>
 | 
						        ---
 | 
				
			||||||
		<a href="{{.Link}}">View it on Gitea</a>.
 | 
						        <br>
 | 
				
			||||||
	</p>
 | 
						        <a href="{{.Link}}">View it on {{AppName}}</a>.
 | 
				
			||||||
 | 
						    </p>
 | 
				
			||||||
 | 
						</div>
 | 
				
			||||||
</body>
 | 
					</body>
 | 
				
			||||||
</html>
 | 
					</html>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user