2019-05-02 17:17:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-12-22 10:08:35 -06:00
|
|
|
class WebHookPostSerializer < PostSerializer
|
2023-01-09 06:20:10 -06:00
|
|
|
attributes :topic_posts_count, :topic_filtered_posts_count, :topic_archetype, :category_slug
|
2018-01-17 12:40:21 -06:00
|
|
|
|
2017-04-20 21:04:21 -05:00
|
|
|
def include_topic_title?
|
|
|
|
true
|
2016-12-22 10:08:35 -06:00
|
|
|
end
|
|
|
|
|
2020-06-10 12:55:03 -05:00
|
|
|
def include_raw?
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2020-09-02 09:42:51 -05:00
|
|
|
def include_category_id?
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2023-01-09 06:20:10 -06:00
|
|
|
%i[
|
2017-04-20 21:04:21 -05:00
|
|
|
can_view
|
|
|
|
can_edit
|
|
|
|
can_delete
|
|
|
|
can_recover
|
2023-05-31 22:32:05 -05:00
|
|
|
can_see_hidden_post
|
2017-04-20 21:04:21 -05:00
|
|
|
can_wiki
|
2018-05-20 21:52:57 -05:00
|
|
|
actions_summary
|
|
|
|
can_view_edit_history
|
|
|
|
yours
|
2021-07-08 02:46:21 -05:00
|
|
|
flair_url
|
|
|
|
flair_bg_color
|
|
|
|
flair_color
|
2020-11-11 06:49:53 -06:00
|
|
|
notice
|
2022-12-06 09:10:36 -06:00
|
|
|
mentioned_users
|
2023-01-09 06:20:10 -06:00
|
|
|
].each { |attr| define_method("include_#{attr}?") { false } }
|
2018-01-17 12:40:21 -06:00
|
|
|
|
|
|
|
def topic_posts_count
|
2018-01-22 11:54:11 -06:00
|
|
|
object.topic ? object.topic.posts_count : 0
|
2018-01-17 12:40:21 -06:00
|
|
|
end
|
|
|
|
|
2019-12-04 11:22:44 -06:00
|
|
|
def topic_filtered_posts_count
|
|
|
|
object.topic ? object.topic.posts.where(post_type: Post.types[:regular]).count : 0
|
|
|
|
end
|
|
|
|
|
2019-10-01 20:41:33 -05:00
|
|
|
def topic_archetype
|
2023-01-09 06:20:10 -06:00
|
|
|
object.topic ? object.topic.archetype : ""
|
2019-10-01 20:41:33 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def include_category_slug?
|
|
|
|
object.topic && object.topic.category
|
|
|
|
end
|
|
|
|
|
|
|
|
def category_slug
|
2023-01-09 06:20:10 -06:00
|
|
|
object.topic && object.topic.category ? object.topic.category.slug_for_url : ""
|
2019-10-01 20:41:33 -05:00
|
|
|
end
|
|
|
|
|
2019-08-27 07:09:00 -05:00
|
|
|
def include_readers_count?
|
|
|
|
false
|
|
|
|
end
|
2016-12-22 10:08:35 -06:00
|
|
|
end
|