A platform for community discussion. Free, open, simple.
FEATURE: Add topic and category context to post webhook payload (#8110)
Ryan Boderb7ebe574df25
diff --git a/app/serializers/web_hook_post_serializer.rb b/app/serializers/web_hook_post_serializer.rbindex 2f78f3ca886..030b55203b7 100644--- a/app/serializers/web_hook_post_serializer.rb+++ b/app/serializers/web_hook_post_serializer.rb@@ -2,7 +2,9 @@class WebHookPostSerializer < PostSerializer- attributes :topic_posts_count+ attributes :topic_posts_count,+ :topic_archetype,+ :category_slugdef include_topic_title?true@@ -32,6 +34,18 @@ class WebHookPostSerializer < PostSerializerobject.topic ? object.topic.posts_count : 0end+ 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?falseenddiff --git a/spec/serializers/web_hook_post_serializer_spec.rb b/spec/serializers/web_hook_post_serializer_spec.rbindex 7d0cae98451..c844fda4b79 100644--- a/spec/serializers/web_hook_post_serializer_spec.rb+++ b/spec/serializers/web_hook_post_serializer_spec.rb@@ -12,7 +12,7 @@ RSpec.describe WebHookPostSerializer doit 'should only include the required keys' docount = serialized_for_user(admin).keys.count- difference = count - 36+ difference = count - 38expect(difference).to eq(0), lambda {message = +""