about summary refs log tree commit diff
path: root/app/controllers/api/v1/accounts/familiar_followers_controller.rb
blob: b0bd8018a2177f000d9c0d27eb72c139b1663d41 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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