mirror of
https://github.com/discourse/discourse.git
synced 2024-12-25 07:23:52 +08:00
d4fb6e1437
The only addition is PosterSerializer is this:
discourse/app/serializers/poster_serializer.rb
Line 4 in 4a5616f
Which allows themes to check the posters' primary group!
37 lines
906 B
Ruby
37 lines
906 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: PosterSerializer, 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
|