about summary refs log tree commit diff
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2020-02-13 16:18:19 -0600
committermultiple creatures <dev@multiple-creature.party>2020-02-13 16:18:19 -0600
commit38c88fd8e84aed59a151126efb2139b6d34a3d36 (patch)
treec4c27f113dd1ea7db362ffa0ae2e191075830709
parente507cdc63e7606daed3ceff4b1f011cb9a37a370 (diff)
check user's sensitive card filter setting in the status controller
-rw-r--r--app/controllers/api/v1/statuses_controller.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/app/controllers/api/v1/statuses_controller.rb b/app/controllers/api/v1/statuses_controller.rb
index 255c48e62..32f496f03 100644
--- a/app/controllers/api/v1/statuses_controller.rb
+++ b/app/controllers/api/v1/statuses_controller.rb
@@ -36,7 +36,7 @@ class Api::V1::StatusesController < Api::BaseController
   def card
     @card = @status.preview_cards.first
 
-    if @card.nil?
+    if @card.nil? || card_filtered?
       render_empty
     else
       render json: @card, serializer: REST::PreviewCardSerializer, monsterfork_api: monsterfork_api
@@ -116,4 +116,8 @@ class Api::V1::StatusesController < Api::BaseController
   def pagination_params(core_params)
     params.slice(:limit).permit(:limit).merge(core_params)
   end
+
+  def card_filtered?
+    !current_user.nil? && current_user.hides_sensitive_cards? && @status.sensitive?
+  end
 end