@@ -33,8 +33,7 @@ func fallbackMailSubject(issue *issues_model.Issue) string {
3333 return fmt .Sprintf ("[%s] %s (#%d)" , issue .Repo .FullName (), issue .Title , issue .Index )
3434}
3535
36- type mailCommentContext struct {
37- context.Context
36+ type mailComment struct {
3837 Issue * issues_model.Issue
3938 Doer * user_model.User
4039 ActionType activities_model.ActionType
@@ -43,7 +42,7 @@ type mailCommentContext struct {
4342 ForceDoerNotification bool
4443}
4544
46- func composeIssueCommentMessages (ctx * mailCommentContext , lang string , recipients []* user_model.User , fromMention bool , info string ) ([]* sender_service.Message , error ) {
45+ func composeIssueCommentMessages (ctx context. Context , comment * mailComment , lang string , recipients []* user_model.User , fromMention bool , info string ) ([]* sender_service.Message , error ) {
4746 var (
4847 subject string
4948 link string
@@ -54,44 +53,44 @@ func composeIssueCommentMessages(ctx *mailCommentContext, lang string, recipient
5453 )
5554
5655 commentType := issues_model .CommentTypeComment
57- if ctx .Comment != nil {
58- commentType = ctx .Comment .Type
59- link = ctx .Issue .HTMLURL () + "#" + ctx .Comment .HashTag ()
56+ if comment .Comment != nil {
57+ commentType = comment .Comment .Type
58+ link = comment .Issue .HTMLURL () + "#" + comment .Comment .HashTag ()
6059 } else {
61- link = ctx .Issue .HTMLURL ()
60+ link = comment .Issue .HTMLURL ()
6261 }
6362
6463 reviewType := issues_model .ReviewTypeComment
65- if ctx .Comment != nil && ctx .Comment .Review != nil {
66- reviewType = ctx .Comment .Review .Type
64+ if comment .Comment != nil && comment .Comment .Review != nil {
65+ reviewType = comment .Comment .Review .Type
6766 }
6867
6968 // This is the body of the new issue or comment, not the mail body
70- rctx := renderhelper .NewRenderContextRepoComment (ctx . Context , ctx .Issue .Repo ).WithUseAbsoluteLink (true )
71- body , err := markdown .RenderString (rctx , ctx .Content )
69+ rctx := renderhelper .NewRenderContextRepoComment (ctx , comment .Issue .Repo ).WithUseAbsoluteLink (true )
70+ body , err := markdown .RenderString (rctx , comment .Content )
7271 if err != nil {
7372 return nil , err
7473 }
7574
7675 if setting .MailService .EmbedAttachmentImages {
77- attEmbedder := newMailAttachmentBase64Embedder (ctx .Doer , ctx .Issue .Repo , maxEmailBodySize )
76+ attEmbedder := newMailAttachmentBase64Embedder (comment .Doer , comment .Issue .Repo , maxEmailBodySize )
7877 bodyAfterEmbedding , err := attEmbedder .Base64InlineImages (ctx , body )
7978 if err != nil {
8079 log .Error ("Failed to embed images in mail body: %v" , err )
8180 } else {
8281 body = bodyAfterEmbedding
8382 }
8483 }
85- actType , actName , tplName := actionToTemplate (ctx .Issue , ctx .ActionType , commentType , reviewType )
84+ actType , actName , tplName := actionToTemplate (comment .Issue , comment .ActionType , commentType , reviewType )
8685
8786 if actName != "new" {
8887 prefix = "Re: "
8988 }
90- fallback = prefix + fallbackMailSubject (ctx .Issue )
89+ fallback = prefix + fallbackMailSubject (comment .Issue )
9190
92- if ctx .Comment != nil && ctx .Comment .Review != nil {
91+ if comment .Comment != nil && comment .Comment .Review != nil {
9392 reviewComments = make ([]* issues_model.Comment , 0 , 10 )
94- for _ , lines := range ctx .Comment .Review .CodeComments {
93+ for _ , lines := range comment .Comment .Review .CodeComments {
9594 for _ , comments := range lines {
9695 reviewComments = append (reviewComments , comments ... )
9796 }
@@ -104,12 +103,12 @@ func composeIssueCommentMessages(ctx *mailCommentContext, lang string, recipient
104103 "FallbackSubject" : fallback ,
105104 "Body" : body ,
106105 "Link" : link ,
107- "Issue" : ctx .Issue ,
108- "Comment" : ctx .Comment ,
109- "IsPull" : ctx .Issue .IsPull ,
110- "User" : ctx .Issue .Repo .MustOwner (ctx ),
111- "Repo" : ctx .Issue .Repo .FullName (),
112- "Doer" : ctx .Doer ,
106+ "Issue" : comment .Issue ,
107+ "Comment" : comment .Comment ,
108+ "IsPull" : comment .Issue .IsPull ,
109+ "User" : comment .Issue .Repo .MustOwner (ctx ),
110+ "Repo" : comment .Issue .Repo .FullName (),
111+ "Doer" : comment .Doer ,
113112 "IsMention" : fromMention ,
114113 "SubjectPrefix" : prefix ,
115114 "ActionType" : actType ,
@@ -140,22 +139,22 @@ func composeIssueCommentMessages(ctx *mailCommentContext, lang string, recipient
140139 }
141140
142141 // Make sure to compose independent messages to avoid leaking user emails
143- msgID := generateMessageIDForIssue (ctx .Issue , ctx .Comment , ctx .ActionType )
144- reference := generateMessageIDForIssue (ctx .Issue , nil , activities_model .ActionType (0 ))
142+ msgID := generateMessageIDForIssue (comment .Issue , comment .Comment , comment .ActionType )
143+ reference := generateMessageIDForIssue (comment .Issue , nil , activities_model .ActionType (0 ))
145144
146145 var replyPayload []byte
147- if ctx .Comment != nil {
148- if ctx .Comment .Type .HasMailReplySupport () {
149- replyPayload , err = incoming_payload .CreateReferencePayload (ctx .Comment )
146+ if comment .Comment != nil {
147+ if comment .Comment .Type .HasMailReplySupport () {
148+ replyPayload , err = incoming_payload .CreateReferencePayload (comment .Comment )
150149 }
151150 } else {
152- replyPayload , err = incoming_payload .CreateReferencePayload (ctx .Issue )
151+ replyPayload , err = incoming_payload .CreateReferencePayload (comment .Issue )
153152 }
154153 if err != nil {
155154 return nil , err
156155 }
157156
158- unsubscribePayload , err := incoming_payload .CreateReferencePayload (ctx .Issue )
157+ unsubscribePayload , err := incoming_payload .CreateReferencePayload (comment .Issue )
159158 if err != nil {
160159 return nil , err
161160 }
@@ -164,7 +163,7 @@ func composeIssueCommentMessages(ctx *mailCommentContext, lang string, recipient
164163 for _ , recipient := range recipients {
165164 msg := sender_service .NewMessageFrom (
166165 recipient .Email ,
167- fromDisplayName (ctx .Doer ),
166+ fromDisplayName (comment .Doer ),
168167 setting .MailService .FromEmail ,
169168 subject ,
170169 mailBody .String (),
@@ -175,7 +174,7 @@ func composeIssueCommentMessages(ctx *mailCommentContext, lang string, recipient
175174 msg .SetHeader ("In-Reply-To" , reference )
176175
177176 references := []string {reference }
178- listUnsubscribe := []string {"<" + ctx .Issue .HTMLURL () + ">" }
177+ listUnsubscribe := []string {"<" + comment .Issue .HTMLURL () + ">" }
179178
180179 if setting .IncomingEmail .Enabled {
181180 if replyPayload != nil {
@@ -203,7 +202,7 @@ func composeIssueCommentMessages(ctx *mailCommentContext, lang string, recipient
203202 msg .SetHeader ("References" , references ... )
204203 msg .SetHeader ("List-Unsubscribe" , listUnsubscribe ... )
205204
206- for key , value := range generateAdditionalHeaders (ctx , actType , recipient ) {
205+ for key , value := range generateAdditionalHeaders (comment , actType , recipient ) {
207206 msg .SetHeader (key , value )
208207 }
209208
@@ -303,7 +302,7 @@ func generateMessageIDForIssue(issue *issues_model.Issue, comment *issues_model.
303302 return fmt .Sprintf ("<%s/%s/%d%s@%s>" , issue .Repo .FullName (), path , issue .Index , extra , setting .Domain )
304303}
305304
306- func generateAdditionalHeaders (ctx * mailCommentContext , reason string , recipient * user_model.User ) map [string ]string {
305+ func generateAdditionalHeaders (ctx * mailComment , reason string , recipient * user_model.User ) map [string ]string {
307306 repo := ctx .Issue .Repo
308307
309308 return map [string ]string {
0 commit comments