about summary refs log tree commit diff
path: root/app/serializers
diff options
context:
space:
mode:
authorFire Demon <firedemon@creature.cafe>2020-07-28 06:57:52 -0500
committerFire Demon <firedemon@creature.cafe>2020-08-30 05:45:16 -0500
commita5a9f95840ea948f6ceeae2790a7fd433febb287 (patch)
tree6a3ff379416d6119182dced7fe5d927c41c40c66 /app/serializers
parent9f6d7e5453fa2f37426127b0f066ca5549e0e024 (diff)
[Privacy, API] Expose domain permissions to author
Diffstat (limited to 'app/serializers')
-rw-r--r--app/serializers/rest/status_serializer.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/app/serializers/rest/status_serializer.rb b/app/serializers/rest/status_serializer.rb
index 1c4b86c21..4b06ec268 100644
--- a/app/serializers/rest/status_serializer.rb
+++ b/app/serializers/rest/status_serializer.rb
@@ -36,6 +36,8 @@ class REST::StatusSerializer < ActiveModel::Serializer
   has_one :preview_card, key: :card, serializer: REST::PreviewCardSerializer
   has_one :preloadable_poll, key: :poll, serializer: REST::PollSerializer
 
+  has_many :domain_permissions, serializer: REST::StatusDomainPermissionSerializer, if: :locally_owned?
+
   def id
     object.id.to_s
   end
@@ -52,8 +54,16 @@ class REST::StatusSerializer < ActiveModel::Serializer
     !current_user.nil?
   end
 
+  def owned?
+    current_user? && current_user.account_id == object.account_id
+  end
+
+  def locally_owned?
+    object.local? && owned?
+  end
+
   def show_application?
-    object.account.user_shows_application? || (current_user? && current_user.account_id == object.account_id)
+    object.account.user_shows_application? || owned?
   end
 
   def visibility