mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-04-08 02:31:36 +02:00
Remove comments related to pending reviews
This adds removal of comments that were submitted as part of a pending review which has been deleted.
This commit is contained in:
parent
5706a2452e
commit
4c7572150b
1 changed files with 15 additions and 0 deletions
|
@ -118,6 +118,9 @@ func UpdateComment(ctx context.Context, c *issues_model.Comment, contentVersion
|
|||
|
||||
// DeleteComment deletes the comment
|
||||
func DeleteComment(ctx context.Context, doer *user_model.User, comment *issues_model.Comment) error {
|
||||
reviewID := comment.ReviewID
|
||||
reviewType := comment.Review.Type
|
||||
|
||||
err := db.WithTx(ctx, func(ctx context.Context) error {
|
||||
return issues_model.DeleteComment(ctx, comment)
|
||||
})
|
||||
|
@ -132,5 +135,17 @@ func DeleteComment(ctx context.Context, doer *user_model.User, comment *issues_m
|
|||
notify_service.DeleteComment(ctx, doer, comment)
|
||||
}
|
||||
|
||||
if reviewType == issues_model.ReviewTypePending {
|
||||
found, err := db.GetEngine(ctx).Table("comment").Where("review_id = ?", reviewID).Exist()
|
||||
if found {
|
||||
_, err := db.GetEngine(ctx).Table("comment").Where("reviewID = ?", reviewID).Delete()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue