discourse/app/serializers/topic_post_count_serializer.rb

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

63 lines
1008 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2013-02-06 03:16:51 +08:00
class TopicPostCountSerializer < BasicUserSerializer
attributes :post_count, :primary_group_name,
:flair_name, :flair_url, :flair_color, :flair_bg_color,
:admin, :moderator, :trust_level,
2013-02-06 03:16:51 +08:00
def id
object[:user].id
end
def username
object[:user].username
end
def post_count
object[:post_count]
end
def primary_group_name
return nil unless object[:user].primary_group_id
object[:user]&.primary_group&.name
end
def flair_name
object[:user]&.flair_group&.name
end
def flair_url
object[:user]&.flair_group&.flair_url
end
def flair_bg_color
object[:user]&.flair_group&.flair_bg_color
end
def flair_color
object[:user]&.flair_group&.flair_color
end
def include_admin?
object[:user].admin
end
def admin
true
end
def include_moderator?
object[:user].moderator
end
def moderator
true
end
def trust_level
object[:user].trust_level
end
2013-02-07 23:45:24 +08:00
end