mirror of
https://github.com/wgh136/nysoure.git
synced 2025-12-16 15:51:14 +00:00
Fix comment deleting
This commit is contained in:
@@ -179,9 +179,11 @@ func DeleteCommentByID(commentID uint) error {
|
|||||||
if err := tx.Model(&model.User{}).Where("id = ?", comment.UserID).Update("comments_count", gorm.Expr("comments_count - 1")).Error; err != nil {
|
if err := tx.Model(&model.User{}).Where("id = ?", comment.UserID).Update("comments_count", gorm.Expr("comments_count - 1")).Error; err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if comment.Type == model.CommentTypeResource {
|
||||||
if err := tx.Model(&model.Resource{}).Where("id = ?", comment.RefID).Update("comments", gorm.Expr("comments - 1")).Error; err != nil {
|
if err := tx.Model(&model.Resource{}).Where("id = ?", comment.RefID).Update("comments", gorm.Expr("comments - 1")).Error; err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if err := tx.
|
if err := tx.
|
||||||
Where("type = ? and ref_id = ?", model.ActivityTypeNewComment, commentID).
|
Where("type = ? and ref_id = ?", model.ActivityTypeNewComment, commentID).
|
||||||
Delete(&model.Activity{}).
|
Delete(&model.Activity{}).
|
||||||
|
|||||||
Reference in New Issue
Block a user