expose account roles to the api

staging
multiple creatures 2019-05-19 10:54:21 -05:00
parent 1244c30349
commit ee83fe92f1
1 changed files with 7 additions and 1 deletions

View File

@ -6,7 +6,7 @@ class REST::AccountSerializer < ActiveModel::Serializer
attributes :id, :username, :acct, :display_name, :locked, :bot, :created_at,
:note, :url, :avatar, :avatar_static, :header, :header_static,
:followers_count, :following_count, :statuses_count, :replies,
:adults_only, :gentlies_kobolds, :is_a_kobold
:adults_only, :gentlies_kobolds, :is_a_kobold, :role
has_one :moved_to_account, key: :moved, serializer: REST::AccountSerializer, if: :moved_and_not_nested?
has_many :emojis, serializer: REST::CustomEmojiSerializer
@ -64,4 +64,10 @@ class REST::AccountSerializer < ActiveModel::Serializer
def is_a_kobold
object.user_is_a_kobold? || false
end
def role
return 'admin' if object.user_admin?
return 'moderator' if object.user_moderator?
'user'
end
end