2014-02-07 09:44:03 -06:00
|
|
|
class GroupPostSerializer < ApplicationSerializer
|
|
|
|
attributes :id,
|
|
|
|
:cooked,
|
|
|
|
:created_at,
|
|
|
|
:title,
|
2014-02-12 13:23:10 -06:00
|
|
|
:url,
|
|
|
|
:user_title,
|
2014-11-14 18:30:05 -06:00
|
|
|
:user_long_name,
|
2016-03-11 02:06:31 -06:00
|
|
|
:topic,
|
2014-11-14 18:30:05 -06:00
|
|
|
:category
|
2014-02-07 09:44:03 -06:00
|
|
|
|
|
|
|
has_one :user, serializer: BasicUserSerializer, embed: :objects
|
|
|
|
|
|
|
|
def title
|
|
|
|
object.topic.title
|
|
|
|
end
|
|
|
|
|
2014-02-12 13:23:10 -06:00
|
|
|
def user_long_name
|
|
|
|
object.user.try(:name)
|
|
|
|
end
|
|
|
|
|
|
|
|
def user_title
|
|
|
|
object.user.try(:title)
|
|
|
|
end
|
|
|
|
|
|
|
|
def include_user_long_name?
|
|
|
|
SiteSetting.enable_names?
|
|
|
|
end
|
2014-11-14 18:30:05 -06:00
|
|
|
|
2016-03-11 02:06:31 -06:00
|
|
|
def topic
|
|
|
|
object.topic
|
|
|
|
end
|
|
|
|
|
2016-04-13 12:24:39 -05:00
|
|
|
def cooked
|
|
|
|
fragment = Nokogiri::HTML.fragment(object.cooked)
|
|
|
|
DiscourseEvent.trigger(:reduce_cooked, fragment, object)
|
|
|
|
fragment.to_html
|
|
|
|
end
|
|
|
|
|
2014-11-14 18:30:05 -06:00
|
|
|
def category
|
|
|
|
object.topic.category
|
|
|
|
end
|
2014-02-07 09:44:03 -06:00
|
|
|
end
|