logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

relationships_controller.rb (775B)


  1. # frozen_string_literal: true
  2. class Api::V1::Accounts::RelationshipsController < Api::BaseController
  3. before_action -> { doorkeeper_authorize! :read }
  4. before_action :require_user!
  5. respond_to :json
  6. def index
  7. accounts = Account.where(id: account_ids).select('id')
  8. # .where doesn't guarantee that our results are in the same order
  9. # we requested them, so return the "right" order to the requestor.
  10. @accounts = accounts.index_by(&:id).values_at(*account_ids).compact
  11. render json: @accounts, each_serializer: REST::RelationshipSerializer, relationships: relationships
  12. end
  13. private
  14. def relationships
  15. AccountRelationshipsPresenter.new(@accounts, current_user.account_id)
  16. end
  17. def account_ids
  18. Array(params[:id]).map(&:to_i)
  19. end
  20. end