relationships_controller.rb 646 B

12345678910111213141516171819202122
  1. # frozen_string_literal: true
  2. class Api::V1::Accounts::RelationshipsController < Api::BaseController
  3. before_action -> { doorkeeper_authorize! :read, :'read:follows' }
  4. before_action :require_user!
  5. def index
  6. @accounts = Account.where(id: account_ids).select('id')
  7. @accounts.merge!(Account.without_suspended) unless truthy_param?(:with_suspended)
  8. render json: @accounts, each_serializer: REST::RelationshipSerializer, relationships: relationships
  9. end
  10. private
  11. def relationships
  12. AccountRelationshipsPresenter.new(@accounts, current_user.account_id)
  13. end
  14. def account_ids
  15. Array(params[:id]).map(&:to_i)
  16. end
  17. end