mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Add topic and category context to post webhook payload (#8110)
Adds additional fields topic_archetype and category_slug to the post webhook so that handlers have some context about the post event without having to call back to the API. Discussed [here](https://meta.discourse.org/t/webhooks-how-best-to-differentiate-a-pm-from-a-public-post/76363/13).
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
|
||||
class WebHookPostSerializer < PostSerializer
|
||||
|
||||
attributes :topic_posts_count
|
||||
attributes :topic_posts_count,
|
||||
:topic_archetype,
|
||||
:category_slug
|
||||
|
||||
def include_topic_title?
|
||||
true
|
||||
@@ -32,6 +34,18 @@ class WebHookPostSerializer < PostSerializer
|
||||
object.topic ? object.topic.posts_count : 0
|
||||
end
|
||||
|
||||
def topic_archetype
|
||||
object.topic ? object.topic.archetype : ''
|
||||
end
|
||||
|
||||
def include_category_slug?
|
||||
object.topic && object.topic.category
|
||||
end
|
||||
|
||||
def category_slug
|
||||
object.topic && object.topic.category ? object.topic.category.slug_for_url : ''
|
||||
end
|
||||
|
||||
def include_readers_count?
|
||||
false
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user