expose account roles to the api
parent
1244c30349
commit
ee83fe92f1
|
@ -6,7 +6,7 @@ class REST::AccountSerializer < ActiveModel::Serializer
|
||||||
attributes :id, :username, :acct, :display_name, :locked, :bot, :created_at,
|
attributes :id, :username, :acct, :display_name, :locked, :bot, :created_at,
|
||||||
:note, :url, :avatar, :avatar_static, :header, :header_static,
|
:note, :url, :avatar, :avatar_static, :header, :header_static,
|
||||||
:followers_count, :following_count, :statuses_count, :replies,
|
: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_one :moved_to_account, key: :moved, serializer: REST::AccountSerializer, if: :moved_and_not_nested?
|
||||||
has_many :emojis, serializer: REST::CustomEmojiSerializer
|
has_many :emojis, serializer: REST::CustomEmojiSerializer
|
||||||
|
@ -64,4 +64,10 @@ class REST::AccountSerializer < ActiveModel::Serializer
|
||||||
def is_a_kobold
|
def is_a_kobold
|
||||||
object.user_is_a_kobold? || false
|
object.user_is_a_kobold? || false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def role
|
||||||
|
return 'admin' if object.user_admin?
|
||||||
|
return 'moderator' if object.user_moderator?
|
||||||
|
'user'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue