about summary refs log tree commit diff
path: root/app/serializers/rest
diff options
context:
space:
mode:
Diffstat (limited to 'app/serializers/rest')
-rw-r--r--app/serializers/rest/status_serializer.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/app/serializers/rest/status_serializer.rb b/app/serializers/rest/status_serializer.rb
index de8d08528..931904636 100644
--- a/app/serializers/rest/status_serializer.rb
+++ b/app/serializers/rest/status_serializer.rb
@@ -32,7 +32,7 @@ class REST::StatusSerializer < ActiveModel::Serializer
   has_many :tags
   has_many :emojis, serializer: REST::CustomEmojiSerializer
 
-  has_one :preview_card, key: :card, serializer: REST::PreviewCardSerializer
+  has_one :preview_card, key: :card, serializer: REST::PreviewCardSerializer, if: :card_not_filtered?
   has_one :preloadable_poll, key: :poll, serializer: REST::PollSerializer
 
   def trans
@@ -152,6 +152,10 @@ class REST::StatusSerializer < ActiveModel::Serializer
     instance_options[:source_requested]
   end
 
+  def card_not_filtered?
+    !(current_user? && current_user.hides_sensitive_cards? && object.sensitive?)
+  end
+
   def ordered_mentions
     object.active_mentions.to_a.sort_by(&:id)
   end