@@ -193,15 +193,29 @@ func SoftDeleteContentHistory(ctx *context.Context) {
193
193
var comment * issues_model.Comment
194
194
var history * issues_model.ContentHistory
195
195
var err error
196
+
197
+ if history , err = issues_model .GetIssueContentHistoryByID (ctx , historyID ); err != nil {
198
+ log .Error ("can not get issue content history %v. err=%v" , historyID , err )
199
+ return
200
+ }
201
+ if history .IssueID != issue .ID {
202
+ ctx .NotFound ("CompareRepoID" , issues_model.ErrCommentNotExist {})
203
+ return
204
+ }
196
205
if commentID != 0 {
206
+ if history .CommentID != commentID {
207
+ ctx .NotFound ("CompareCommentID" , issues_model.ErrCommentNotExist {})
208
+ return
209
+ }
210
+
197
211
if comment , err = issues_model .GetCommentByID (ctx , commentID ); err != nil {
198
212
log .Error ("can not get comment for issue content history %v. err=%v" , historyID , err )
199
213
return
200
214
}
201
- }
202
- if history , err = issues_model . GetIssueContentHistoryByID ( ctx , historyID ); err != nil {
203
- log . Error ( "can not get issue content history %v. err=%v" , historyID , err )
204
- return
215
+ if comment . IssueID != issue . ID {
216
+ ctx . NotFound ( "CompareIssueID" , issues_model. ErrCommentNotExist {})
217
+ return
218
+ }
205
219
}
206
220
207
221
canSoftDelete := canSoftDeleteContentHistory (ctx , issue , comment , history )
0 commit comments