@@ -193,15 +193,29 @@ func SoftDeleteContentHistory(ctx *context.Context) {
193193 var comment * issues_model.Comment
194194 var history * issues_model.ContentHistory
195195 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+ }
196205 if commentID != 0 {
206+ if history .CommentID != commentID {
207+ ctx .NotFound ("CompareCommentID" , issues_model.ErrCommentNotExist {})
208+ return
209+ }
210+
197211 if comment , err = issues_model .GetCommentByID (ctx , commentID ); err != nil {
198212 log .Error ("can not get comment for issue content history %v. err=%v" , historyID , err )
199213 return
200214 }
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+ }
205219 }
206220
207221 canSoftDelete := canSoftDeleteContentHistory (ctx , issue , comment , history )
0 commit comments