mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-31 11:28:24 +00:00 
			
		
		
		
	Include username in email headers (#28981)
Emails from Gitea comments do not contain the username of the commenter anywhere, only their display name, so it is not possible to verify who made a comment from the email itself: From: "Alice" <email@gitea> X-Gitea-Sender: Alice X-Gitea-Recipient: Bob X-GitHub-Sender: Alice X-GitHub-Recipient: Bob This comment looks like it's from @alice. The X-Gitea/X-GitHub headers also use display names, which is not very reliable for filtering, and inconsistent with GitHub's behavior: X-GitHub-Sender: lunny X-GitHub-Recipient: gwymor This change includes both the display name and username in the From header, and switches the other headers from display name to username: From: "Alice (@fakealice)" <email@gitea> X-Gitea-Sender: fakealice X-Gitea-Recipient: bob X-GitHub-Sender: fakealice X-GitHub-Recipient: bob This comment looks like it's from @alice.
This commit is contained in:
		| @@ -310,7 +310,13 @@ func composeIssueCommentMessages(ctx *mailCommentContext, lang string, recipient | ||||
|  | ||||
| 	msgs := make([]*Message, 0, len(recipients)) | ||||
| 	for _, recipient := range recipients { | ||||
| 		msg := NewMessageFrom(recipient.Email, ctx.Doer.DisplayName(), setting.MailService.FromEmail, subject, mailBody.String()) | ||||
| 		msg := NewMessageFrom( | ||||
| 			recipient.Email, | ||||
| 			ctx.Doer.GetCompleteName(), | ||||
| 			setting.MailService.FromEmail, | ||||
| 			subject, | ||||
| 			mailBody.String(), | ||||
| 		) | ||||
| 		msg.Info = fmt.Sprintf("Subject: %s, %s", subject, info) | ||||
|  | ||||
| 		msg.SetHeader("Message-ID", msgID) | ||||
| @@ -394,8 +400,8 @@ func generateAdditionalHeaders(ctx *mailCommentContext, reason string, recipient | ||||
|  | ||||
| 		"X-Mailer":                  "Gitea", | ||||
| 		"X-Gitea-Reason":            reason, | ||||
| 		"X-Gitea-Sender":            ctx.Doer.DisplayName(), | ||||
| 		"X-Gitea-Recipient":         recipient.DisplayName(), | ||||
| 		"X-Gitea-Sender":            ctx.Doer.Name, | ||||
| 		"X-Gitea-Recipient":         recipient.Name, | ||||
| 		"X-Gitea-Recipient-Address": recipient.Email, | ||||
| 		"X-Gitea-Repository":        repo.Name, | ||||
| 		"X-Gitea-Repository-Path":   repo.FullName(), | ||||
| @@ -404,8 +410,8 @@ func generateAdditionalHeaders(ctx *mailCommentContext, reason string, recipient | ||||
| 		"X-Gitea-Issue-Link":        ctx.Issue.HTMLURL(), | ||||
|  | ||||
| 		"X-GitHub-Reason":            reason, | ||||
| 		"X-GitHub-Sender":            ctx.Doer.DisplayName(), | ||||
| 		"X-GitHub-Recipient":         recipient.DisplayName(), | ||||
| 		"X-GitHub-Sender":            ctx.Doer.Name, | ||||
| 		"X-GitHub-Recipient":         recipient.Name, | ||||
| 		"X-GitHub-Recipient-Address": recipient.Email, | ||||
|  | ||||
| 		"X-GitLab-NotificationReason": reason, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user