discourse/app/serializers/web_hook_post_serializer.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

65 lines
1.1 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
class WebHookPostSerializer < PostSerializer
attributes :topic_posts_count,
:topic_filtered_posts_count,
:topic_archetype,
:category_slug
def include_topic_title?
true
end
def include_raw?
true
end
def include_category_id?
true
end
%i{
can_view
can_edit
can_delete
can_recover
can_wiki
2018-05-20 22:52:57 -04:00
actions_summary
can_view_edit_history
yours
flair_url
flair_bg_color
flair_color
notice
}.each do |attr|
define_method("include_#{attr}?") do
false
end
end
def topic_posts_count
object.topic ? object.topic.posts_count : 0
end
def topic_filtered_posts_count
object.topic ? object.topic.posts.where(post_type: Post.types[:regular]).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
end