77	"bytes" 
88	"context" 
99	"fmt" 
10+ 	"maps" 
1011	"strconv" 
1112	"strings" 
1213	"time" 
@@ -29,7 +30,7 @@ import (
2930// Many e-mail service providers have limitations on the size of the email body, it's usually from 10MB to 25MB 
3031const  maxEmailBodySize  =  9_000_000 
3132
32- func  fallbackMailSubject (issue  * issues_model.Issue ) string  {
33+ func  fallbackIssueMailSubject (issue  * issues_model.Issue ) string  {
3334	return  fmt .Sprintf ("[%s] %s (#%d)" , issue .Repo .FullName (), issue .Title , issue .Index )
3435}
3536
@@ -86,7 +87,7 @@ func composeIssueCommentMessages(ctx context.Context, comment *mailComment, lang
8687	if  actName  !=  "new"  {
8788		prefix  =  "Re: " 
8889	}
89- 	fallback  =  prefix  +  fallbackMailSubject (comment .Issue )
90+ 	fallback  =  prefix  +  fallbackIssueMailSubject (comment .Issue )
9091
9192	if  comment .Comment  !=  nil  &&  comment .Comment .Review  !=  nil  {
9293		reviewComments  =  make ([]* issues_model.Comment , 0 , 10 )
@@ -202,7 +203,7 @@ func composeIssueCommentMessages(ctx context.Context, comment *mailComment, lang
202203		msg .SetHeader ("References" , references ... )
203204		msg .SetHeader ("List-Unsubscribe" , listUnsubscribe ... )
204205
205- 		for  key , value  :=  range  generateAdditionalHeaders (comment , actType , recipient ) {
206+ 		for  key , value  :=  range  generateAdditionalHeadersForIssue (comment , actType , recipient ) {
206207			msg .SetHeader (key , value )
207208		}
208209
@@ -302,35 +303,18 @@ func generateMessageIDForIssue(issue *issues_model.Issue, comment *issues_model.
302303	return  fmt .Sprintf ("<%s/%s/%d%s@%s>" , issue .Repo .FullName (), path , issue .Index , extra , setting .Domain )
303304}
304305
305- func  generateAdditionalHeaders (ctx  * mailComment , reason  string , recipient  * user_model.User ) map [string ]string  {
306+ func  generateAdditionalHeadersForIssue (ctx  * mailComment , reason  string , recipient  * user_model.User ) map [string ]string  {
306307	repo  :=  ctx .Issue .Repo 
307308
308- 	return  map [string ]string {
309- 		// https://datatracker.ietf.org/doc/html/rfc2919 
310- 		"List-ID" : fmt .Sprintf ("%s <%s.%s.%s>" , repo .FullName (), repo .Name , repo .OwnerName , setting .Domain ),
311- 
312- 		// https://datatracker.ietf.org/doc/html/rfc2369 
313- 		"List-Archive" : fmt .Sprintf ("<%s>" , repo .HTMLURL ()),
314- 
315- 		"X-Mailer" :                  "Gitea" ,
316- 		"X-Gitea-Reason" :            reason ,
317- 		"X-Gitea-Sender" :            ctx .Doer .Name ,
318- 		"X-Gitea-Recipient" :         recipient .Name ,
319- 		"X-Gitea-Recipient-Address" : recipient .Email ,
320- 		"X-Gitea-Repository" :        repo .Name ,
321- 		"X-Gitea-Repository-Path" :   repo .FullName (),
322- 		"X-Gitea-Repository-Link" :   repo .HTMLURL (),
323- 		"X-Gitea-Issue-ID" :          strconv .FormatInt (ctx .Issue .Index , 10 ),
324- 		"X-Gitea-Issue-Link" :        ctx .Issue .HTMLURL (),
325- 
326- 		"X-GitHub-Reason" :            reason ,
327- 		"X-GitHub-Sender" :            ctx .Doer .Name ,
328- 		"X-GitHub-Recipient" :         recipient .Name ,
329- 		"X-GitHub-Recipient-Address" : recipient .Email ,
330- 
331- 		"X-GitLab-NotificationReason" : reason ,
332- 		"X-GitLab-Project" :            repo .Name ,
333- 		"X-GitLab-Project-Path" :       repo .FullName (),
334- 		"X-GitLab-Issue-IID" :          strconv .FormatInt (ctx .Issue .Index , 10 ),
335- 	}
309+ 	issueID  :=  strconv .FormatInt (ctx .Issue .Index , 10 )
310+ 	headers  :=  generateMetadataHeaders (repo )
311+ 
312+ 	maps .Copy (headers , generateSenderRecipientHeaders (ctx .Doer , recipient ))
313+ 	maps .Copy (headers , generateReasonHeaders (reason ))
314+ 
315+ 	headers ["X-Gitea-Issue-ID" ] =  issueID 
316+ 	headers ["X-Gitea-Issue-Link" ] =  ctx .Issue .HTMLURL ()
317+ 	headers ["X-GitLab-Issue-IID" ] =  issueID 
318+ 
319+ 	return  headers 
336320}
0 commit comments