discourse/app/serializers/suggested_topic_serializer.rb

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

37 lines
909 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class SuggestedTopicSerializer < ListableTopicSerializer
2018-02-14 04:46:25 +08:00
include TopicTagsMixin
2013-02-06 03:16:51 +08:00
# need to embed so we have users
# front page json gets away without embedding
class SuggestedPosterSerializer < ApplicationSerializer
attributes :extras, :description
has_one :user, serializer: BasicUserSerializer, embed: :objects
end
2018-02-14 04:46:25 +08:00
attributes :archetype,
:like_count,
:views,
:category_id,
:featured_link,
:featured_link_root_domain
has_many :posters, serializer: SuggestedPosterSerializer, embed: :objects
def posters
object.posters || []
end
def include_featured_link?
SiteSetting.topic_featured_link_enabled
end
def featured_link
object.featured_link
end
def include_featured_link_root_domain?
SiteSetting.topic_featured_link_enabled && object.featured_link
end
2013-02-06 03:16:51 +08:00
end