The code powering m.abunchtell.com https://m.abunchtell.com
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 

27 řádky
792 B

  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. 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