suggestions_controller.rb 696 B

12345678910111213141516171819202122232425
  1. # frozen_string_literal: true
  2. class Api::V1::SuggestionsController < Api::BaseController
  3. include Authorization
  4. before_action -> { doorkeeper_authorize! :read, :'read:accounts' }, only: :index
  5. before_action -> { doorkeeper_authorize! :write, :'write:accounts' }, except: :index
  6. before_action :require_user!
  7. before_action :set_suggestions
  8. def index
  9. render json: @suggestions.get(limit_param(DEFAULT_ACCOUNTS_LIMIT), params[:offset].to_i).map(&:account), each_serializer: REST::AccountSerializer
  10. end
  11. def destroy
  12. @suggestions.remove(params[:id])
  13. render_empty
  14. end
  15. private
  16. def set_suggestions
  17. @suggestions = AccountSuggestions.new(current_account)
  18. end
  19. end