@@ -82,43 +82,40 @@ func (h *ReplyHandler) Handle(ctx context.Context, content *MailContent, doer *u
82
82
return nil
83
83
}
84
84
85
- switch r := ref .(type ) {
86
- case * issues_model.Issue :
87
- attachmentIDs := make ([]string , 0 , len (content .Attachments ))
88
- if setting .Attachment .Enabled {
89
- for _ , attachment := range content .Attachments {
90
- a , err := attachment_service .UploadAttachment (ctx , bytes .NewReader (attachment .Content ), setting .Attachment .AllowedTypes , int64 (len (attachment .Content )), & repo_model.Attachment {
91
- Name : attachment .Name ,
92
- UploaderID : doer .ID ,
93
- RepoID : issue .Repo .ID ,
94
- })
95
- if err != nil {
96
- if upload .IsErrFileTypeForbidden (err ) {
97
- log .Info ("Skipping disallowed attachment type: %s" , attachment .Name )
98
- continue
99
- }
100
- return err
85
+ attachmentIDs := make ([]string , 0 , len (content .Attachments ))
86
+ if setting .Attachment .Enabled {
87
+ for _ , attachment := range content .Attachments {
88
+ a , err := attachment_service .UploadAttachment (ctx , bytes .NewReader (attachment .Content ), setting .Attachment .AllowedTypes , int64 (len (attachment .Content )), & repo_model.Attachment {
89
+ Name : attachment .Name ,
90
+ UploaderID : doer .ID ,
91
+ RepoID : issue .Repo .ID ,
92
+ })
93
+ if err != nil {
94
+ if upload .IsErrFileTypeForbidden (err ) {
95
+ log .Info ("Skipping disallowed attachment type: %s" , attachment .Name )
96
+ continue
101
97
}
102
- attachmentIDs = append ( attachmentIDs , a . UUID )
98
+ return err
103
99
}
100
+ attachmentIDs = append (attachmentIDs , a .UUID )
104
101
}
102
+ }
105
103
106
- if content .Content == "" && len (attachmentIDs ) == 0 {
107
- return nil
108
- }
104
+ if content .Content == "" && len (attachmentIDs ) == 0 {
105
+ return nil
106
+ }
109
107
110
- _ , err = issue_service .CreateIssueComment (ctx , doer , issue .Repo , issue , content .Content , attachmentIDs )
108
+ switch r := ref .(type ) {
109
+ case * issues_model.Issue :
110
+ _ , err := issue_service .CreateIssueComment (ctx , doer , issue .Repo , issue , content .Content , attachmentIDs )
111
111
if err != nil {
112
112
return fmt .Errorf ("CreateIssueComment failed: %w" , err )
113
113
}
114
114
case * issues_model.Comment :
115
115
comment := r
116
116
117
- if content .Content == "" {
118
- return nil
119
- }
120
-
121
- if comment .Type == issues_model .CommentTypeCode {
117
+ switch comment .Type {
118
+ case issues_model .CommentTypeCode :
122
119
_ , err := pull_service .CreateCodeComment (
123
120
ctx ,
124
121
doer ,
@@ -130,11 +127,16 @@ func (h *ReplyHandler) Handle(ctx context.Context, content *MailContent, doer *u
130
127
false , // not pending review but a single review
131
128
comment .ReviewID ,
132
129
"" ,
133
- nil ,
130
+ attachmentIDs ,
134
131
)
135
132
if err != nil {
136
133
return fmt .Errorf ("CreateCodeComment failed: %w" , err )
137
134
}
135
+ default :
136
+ _ , err := issue_service .CreateIssueComment (ctx , doer , issue .Repo , issue , content .Content , attachmentIDs )
137
+ if err != nil {
138
+ return fmt .Errorf ("CreateIssueComment failed: %w" , err )
139
+ }
138
140
}
139
141
}
140
142
return nil
0 commit comments