about summary refs log tree commit diff
path: root/app/controllers/api/v1/accounts/familiar_followers_controller.rb
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-03-08 22:40:21 +0100
committerGitHub <noreply@github.com>2022-03-08 22:40:21 +0100
commit02133866e6915e37431298b396e1aded1e4c44c5 (patch)
tree4ec43c5d1269ef7d5a3816a4d000bb7129bf81bd /app/controllers/api/v1/accounts/familiar_followers_controller.rb
parentf03148f441d8dfc1856451c4faa00b5e26b6e199 (diff)
parent481f7c8c3850a5d38e92222ab14e5229c49c2812 (diff)
Merge pull request #1713 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/controllers/api/v1/accounts/familiar_followers_controller.rb')
-rw-r--r--app/controllers/api/v1/accounts/familiar_followers_controller.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/app/controllers/api/v1/accounts/familiar_followers_controller.rb b/app/controllers/api/v1/accounts/familiar_followers_controller.rb
new file mode 100644
index 000000000..b0bd8018a
--- /dev/null
+++ b/app/controllers/api/v1/accounts/familiar_followers_controller.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+class Api::V1::Accounts::FamiliarFollowersController < Api::BaseController
+  before_action -> { doorkeeper_authorize! :read, :'read:follows' }
+  before_action :require_user!
+  before_action :set_accounts
+
+  def index
+    render json: familiar_followers.accounts, each_serializer: REST::FamiliarFollowersSerializer
+  end
+
+  private
+
+  def set_accounts
+    @accounts = Account.without_suspended.where(id: account_ids).select('id, hide_collections').index_by(&:id).values_at(*account_ids).compact
+  end
+
+  def familiar_followers
+    FamiliarFollowersPresenter.new(@accounts, current_user.account_id)
+  end
+
+  def account_ids
+    Array(params[:id]).map(&:to_i)
+  end
+end