about summary refs log tree commit diff
path: root/app/serializers/rest
diff options
context:
space:
mode:
authorFire Demon <firedemon@creature.cafe>2020-07-21 01:44:16 -0500
committerFire Demon <firedemon@creature.cafe>2020-08-30 05:44:01 -0500
commit263ead73616dba43a0337c2a3edaf96a6382d533 (patch)
treeca47a9366dbbdf95018c55bde32b59d6b05c8299 /app/serializers/rest
parent21de9efc2d89ce8dbb9edb997f8a3b99f831d05a (diff)
[Feature] Add post and thread (un)hiding to backend
Diffstat (limited to 'app/serializers/rest')
-rw-r--r--app/serializers/rest/status_serializer.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/app/serializers/rest/status_serializer.rb b/app/serializers/rest/status_serializer.rb
index 7a2dd6db9..1db3d50f1 100644
--- a/app/serializers/rest/status_serializer.rb
+++ b/app/serializers/rest/status_serializer.rb
@@ -21,6 +21,8 @@ class REST::StatusSerializer < ActiveModel::Serializer
   attribute :content_type, if: :source_requested?
 
   attribute :published if :local?
+  attribute :hidden, if: :current_user?
+  attribute :conversation_hidden, if: :current_user?
 
   belongs_to :reblog, serializer: REST::StatusSerializer
   belongs_to :application, if: :show_application?
@@ -101,6 +103,22 @@ class REST::StatusSerializer < ActiveModel::Serializer
     end
   end
 
+  def conversation_hidden
+    if instance_options && instance_options[:relationships]
+      instance_options[:relationships].hidden_conversations_map[object.conversation_id] || false
+    else
+      current_user.account.hiding_conversation?(object.conversation)
+    end
+  end
+
+  def hidden
+    if instance_options && instance_options[:relationships]
+      instance_options[:relationships].hidden_statuses_map[object.id] || false
+    else
+      current_user.account.muting_status?(object)
+    end
+  end
+
   def bookmarked
     if instance_options && instance_options[:relationships]
       instance_options[:relationships].bookmarks_map[object.id] || false