FIX: topic post counts for webhook post_destroyed event (#29853)

* FIX: topic post counts for webhook post_destroyed event

- Generate webhook data after posts are destroyed
- Don't count user_deleted posts

* Remove unnecessary conditional
This commit is contained in:
Angus McLeod
2024-11-27 20:36:51 +01:00
committed by GitHub
parent 8c311dcbd5
commit 6acf673f8d
3 changed files with 37 additions and 15 deletions

View File

@@ -32,12 +32,16 @@ class WebHookPostSerializer < PostSerializer
mentioned_users
].each { |attr| define_method("include_#{attr}?") { false } }
def topic_posts
@topic_posts ||= object.topic.posts.where(user_deleted: false)
end
def topic_posts_count
object.topic ? object.topic.posts_count : 0
object.topic ? topic_posts.count : 0
end
def topic_filtered_posts_count
object.topic ? object.topic.posts.where(post_type: Post.types[:regular]).count : 0
object.topic ? topic_posts.where(post_type: Post.types[:regular]).count : 0
end
def topic_archetype