From ee83fe92f170fd5bfe2d037e3c27bc895a67073b Mon Sep 17 00:00:00 2001 From: multiple creatures Date: Sun, 19 May 2019 10:54:21 -0500 Subject: expose account roles to the api --- app/serializers/rest/account_serializer.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'app/serializers') diff --git a/app/serializers/rest/account_serializer.rb b/app/serializers/rest/account_serializer.rb index 019bac26a..7716aafde 100644 --- a/app/serializers/rest/account_serializer.rb +++ b/app/serializers/rest/account_serializer.rb @@ -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 -- cgit