about summary refs log tree commit diff
path: root/app/serializers/rest
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2023-01-26 19:31:39 +0100
committerClaire <claire.github-309c@sitedethib.com>2023-01-26 19:31:39 +0100
commitfad6633156cae8ab2a7bad0c9802cf7918964ef4 (patch)
treebacf2c029e83fcdc93a9223d57fc4319c4c0872e /app/serializers/rest
parent7acf26e7778f8bb2b62c61904547dec75723c203 (diff)
parent13a2abacc8f943e2b1d2da63551443887e1065b0 (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Diffstat (limited to 'app/serializers/rest')
-rw-r--r--app/serializers/rest/account_serializer.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/app/serializers/rest/account_serializer.rb b/app/serializers/rest/account_serializer.rb
index 6152d54f7..c4e281b80 100644
--- a/app/serializers/rest/account_serializer.rb
+++ b/app/serializers/rest/account_serializer.rb
@@ -26,6 +26,16 @@ class REST::AccountSerializer < ActiveModel::Serializer
     end
   end
 
+  class RoleSerializer < ActiveModel::Serializer
+    attributes :id, :name, :color
+
+    def id
+      object.id.to_s
+    end
+  end
+
+  has_many :roles, serializer: RoleSerializer, if: :local?
+
   class FieldSerializer < ActiveModel::Serializer
     include FormattingHelper
 
@@ -118,6 +128,14 @@ class REST::AccountSerializer < ActiveModel::Serializer
     object.silenced?
   end
 
+  def roles
+    if object.suspended?
+      []
+    else
+      [object.user.role].compact.filter { |role| role.highlighted? }
+    end
+  end
+
   def noindex
     object.user_prefers_noindex?
   end