about summary refs log tree commit diff
path: root/app/controllers/follower_accounts_controller.rb
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2020-03-09 00:10:29 +0100
committerGitHub <noreply@github.com>2020-03-09 00:10:29 +0100
commitb154428e14861f5cdc7ba6e5f8e582dbf7d0a1c0 (patch)
treece3ebad6225a4bf7ed466251c4c3d46b1c0d3ba6 /app/controllers/follower_accounts_controller.rb
parent9660aa4543deff41c60d131e081137f84e771499 (diff)
Add federation support for the "hide network" preference (#11673)
* Change ActivityPub follower/following collections to not link first page

* Add support for hiding followers and following of remote users

* Switch to using a single `hide_collections` column

* Address code style remarks
Diffstat (limited to 'app/controllers/follower_accounts_controller.rb')
-rw-r--r--app/controllers/follower_accounts_controller.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/app/controllers/follower_accounts_controller.rb b/app/controllers/follower_accounts_controller.rb
index 7103749ad..14e22dd1e 100644
--- a/app/controllers/follower_accounts_controller.rb
+++ b/app/controllers/follower_accounts_controller.rb
@@ -28,7 +28,8 @@ class FollowerAccountsController < ApplicationController
         render json: collection_presenter,
                serializer: ActivityPub::CollectionSerializer,
                adapter: ActivityPub::Adapter,
-               content_type: 'application/activity+json'
+               content_type: 'application/activity+json',
+               fields: restrict_fields_to
       end
     end
   end
@@ -71,4 +72,12 @@ class FollowerAccountsController < ApplicationController
       )
     end
   end
+
+  def restrict_fields_to
+    if page_requested? || !@account.user_hides_network?
+      # Return all fields
+    else
+      %i(id type totalItems)
+    end
+  end
 end