@@ -29,7 +29,7 @@ import (
2929// Many e-mail service providers have limitations on the size of the email body, it's usually from 10MB to 25MB
3030const maxEmailBodySize = 9_000_000
3131
32- func fallbackMailSubject (issue * issues_model.Issue ) string {
32+ func fallbackIssueMailSubject (issue * issues_model.Issue ) string {
3333 return fmt .Sprintf ("[%s] %s (#%d)" , issue .Repo .FullName (), issue .Title , issue .Index )
3434}
3535
@@ -86,7 +86,7 @@ func composeIssueCommentMessages(ctx context.Context, comment *mailComment, lang
8686 if actName != "new" {
8787 prefix = "Re: "
8888 }
89- fallback = prefix + fallbackMailSubject (comment .Issue )
89+ fallback = prefix + fallbackIssueMailSubject (comment .Issue )
9090
9191 if comment .Comment != nil && comment .Comment .Review != nil {
9292 reviewComments = make ([]* issues_model.Comment , 0 , 10 )
@@ -202,7 +202,7 @@ func composeIssueCommentMessages(ctx context.Context, comment *mailComment, lang
202202 msg .SetHeader ("References" , references ... )
203203 msg .SetHeader ("List-Unsubscribe" , listUnsubscribe ... )
204204
205- for key , value := range generateAdditionalHeaders (comment , actType , recipient ) {
205+ for key , value := range generateAdditionalHeadersForIssue (comment , actType , recipient ) {
206206 msg .SetHeader (key , value )
207207 }
208208
@@ -302,35 +302,24 @@ func generateMessageIDForIssue(issue *issues_model.Issue, comment *issues_model.
302302 return fmt .Sprintf ("<%s/%s/%d%s@%s>" , issue .Repo .FullName (), path , issue .Index , extra , setting .Domain )
303303}
304304
305- func generateAdditionalHeaders (ctx * mailComment , reason string , recipient * user_model.User ) map [string ]string {
305+ func generateAdditionalHeadersForIssue (ctx * mailComment , reason string , recipient * user_model.User ) map [string ]string {
306306 repo := ctx .Issue .Repo
307307
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 ),
308+ issueID := strconv .FormatInt (ctx .Issue .Index , 10 )
309+ headers := generateMetadataHeaders (repo )
310+
311+ for k , v := range generateSenderRecipientHeaders (ctx .Doer , recipient ) {
312+ headers [k ] = v
313+ }
314+ for k , v := range generateReasonHeaders (reason ) {
315+ headers [k ] = v
335316 }
317+
318+ headers ["X-Gitea-Recipient-Address" ] = recipient .Email
319+ headers ["X-Gitea-Issue-ID" ] = issueID
320+ headers ["X-Gitea-Issue-Link" ] = ctx .Issue .HTMLURL ()
321+ headers ["X-GitHub-Recipient-Address" ] = recipient .Email
322+ headers ["X-GitLab-Issue-IID" ] = issueID
323+
324+ return headers
336325}
0 commit comments