2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-12-22 11:08:35 -05:00
|
|
|
class WebHookPostSerializer < PostSerializer
|
2018-01-17 13:40:21 -05:00
|
|
|
|
2019-10-01 21:41:33 -04:00
|
|
|
attributes :topic_posts_count,
|
2019-12-04 12:22:44 -05:00
|
|
|
:topic_filtered_posts_count,
|
2019-10-01 21:41:33 -04:00
|
|
|
:topic_archetype,
|
|
|
|
:category_slug
|
2018-01-17 13:40:21 -05:00
|
|
|
|
2017-04-20 22:04:21 -04:00
|
|
|
def include_topic_title?
|
|
|
|
true
|
2016-12-22 11:08:35 -05:00
|
|
|
end
|
|
|
|
|
2020-06-10 13:55:03 -04:00
|
|
|
def include_raw?
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2020-09-02 10:42:51 -04:00
|
|
|
def include_category_id?
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2017-04-20 22:04:21 -04:00
|
|
|
%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
|
|
|
|
primary_group_flair_url
|
|
|
|
primary_group_flair_bg_color
|
|
|
|
primary_group_flair_color
|
2020-11-11 07:49:53 -05:00
|
|
|
notice
|
2017-04-20 22:04:21 -04:00
|
|
|
}.each do |attr|
|
|
|
|
define_method("include_#{attr}?") do
|
|
|
|
false
|
|
|
|
end
|
2016-12-22 11:08:35 -05:00
|
|
|
end
|
2018-01-17 13:40:21 -05:00
|
|
|
|
|
|
|
def topic_posts_count
|
2018-01-22 12:54:11 -05:00
|
|
|
object.topic ? object.topic.posts_count : 0
|
2018-01-17 13:40:21 -05:00
|
|
|
end
|
|
|
|
|
2019-12-04 12:22:44 -05:00
|
|
|
def topic_filtered_posts_count
|
|
|
|
object.topic ? object.topic.posts.where(post_type: Post.types[:regular]).count : 0
|
|
|
|
end
|
|
|
|
|
2019-10-01 21:41:33 -04:00
|
|
|
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
|
|
|
|
|
2019-08-27 08:09:00 -04:00
|
|
|
def include_readers_count?
|
|
|
|
false
|
|
|
|
end
|
2016-12-22 11:08:35 -05:00
|
|
|
end
|