discourse/app/serializers/suggested_topic_serializer.rb
Sam Saffron 30990006a9 DEV: enable frozen string literal on all files
This reduces chances of errors where consumers of strings mutate inputs
and reduces memory usage of the app.

Test suite passes now, but there may be some stuff left, so we will run
a few sites on a branch prior to merging
2019-05-13 09:31:32 +08:00

32 lines
844 B
Ruby

# frozen_string_literal: true
class SuggestedTopicSerializer < ListableTopicSerializer
include TopicTagsMixin
# 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
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
end