File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -197,18 +197,22 @@ def unpin_comment(comment: Comment):
197197
198198@transaction .atomic
199199def soft_delete_comment (comment : Comment ):
200- post = comment .on_post
200+ if comment .is_soft_deleted :
201+ return
201202
202- # Decrement counter during comment deletion
203- post .snapshots .filter (viewed_at__gte = comment .created_at ).update (
204- comments_count = F ("comments_count" ) - 1
205- )
203+ post = comment .on_post
206204
207205 comment .is_soft_deleted = True
208206 comment .save (update_fields = ["is_soft_deleted" ])
209207
210208 post .update_comment_count ()
211209
210+ if not comment .is_private :
211+ # Decrement counter during comment deletion
212+ post .snapshots .filter (viewed_at__gte = comment .created_at ).update (
213+ comments_count = F ("comments_count" ) - 1
214+ )
215+
212216
213217def compute_comment_score (
214218 comment_votes : int ,
You can’t perform that action at this time.
0 commit comments