about summary refs log tree commit diff
path: root/app/controllers/activitypub/collections_controller.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2020-05-03 16:30:36 +0200
committerGitHub <noreply@github.com>2020-05-03 16:30:36 +0200
commit988b0493fea7a850130b83d0e81675bda8dd9d8e (patch)
tree0d9cdb503c8f0fe131e01cfdbf61ab85dcd1f296 /app/controllers/activitypub/collections_controller.rb
parenta1062df1e1bc15d32a3afe3054d1e0063a4beb93 (diff)
Add more tests for ActivityPub controllers (#13585)
Diffstat (limited to 'app/controllers/activitypub/collections_controller.rb')
-rw-r--r--app/controllers/activitypub/collections_controller.rb17
1 files changed, 10 insertions, 7 deletions
diff --git a/app/controllers/activitypub/collections_controller.rb b/app/controllers/activitypub/collections_controller.rb
index 910fefb1c..c1e7aa550 100644
--- a/app/controllers/activitypub/collections_controller.rb
+++ b/app/controllers/activitypub/collections_controller.rb
@@ -24,20 +24,23 @@ class ActivityPub::CollectionsController < ActivityPub::BaseController
   def set_size
     case params[:id]
     when 'featured'
-      @account.pinned_statuses.count
+      @size = @account.pinned_statuses.count
     else
-      raise ActiveRecord::RecordNotFound
+      not_found
     end
   end
 
   def scope_for_collection
     case params[:id]
     when 'featured'
-      return Status.none if @account.blocking?(signed_request_account)
-
-      @account.pinned_statuses
-    else
-      raise ActiveRecord::RecordNotFound
+      # Because in public fetch mode we cache the response, there would be no
+      # benefit from performing the check below, since a blocked account or domain
+      # would likely be served the cache from the reverse proxy anyway
+      if authorized_fetch_mode? && !signed_request_account.nil? && (@account.blocking?(signed_request_account) || (!signed_request_account.domain.nil? && @account.domain_blocking?(signed_request_account.domain)))
+        Status.none
+      else
+        @account.pinned_statuses
+      end
     end
   end