2021-04-12 06:37:14 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Api::V2::SuggestionsController < Api::BaseController
|
|
|
|
include Authorization
|
|
|
|
|
2023-12-19 05:59:43 -05:00
|
|
|
before_action -> { doorkeeper_authorize! :read, :'read:accounts' }, only: :index
|
|
|
|
before_action -> { doorkeeper_authorize! :write, :'write:accounts' }, except: :index
|
2021-04-12 06:37:14 -04:00
|
|
|
before_action :require_user!
|
|
|
|
before_action :set_suggestions
|
|
|
|
|
|
|
|
def index
|
2023-12-19 05:59:43 -05:00
|
|
|
render json: @suggestions.get(limit_param(DEFAULT_ACCOUNTS_LIMIT), params[:offset].to_i), each_serializer: REST::SuggestionSerializer
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@suggestions.remove(params[:id])
|
|
|
|
render_empty
|
2021-04-12 06:37:14 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def set_suggestions
|
2023-12-19 05:59:43 -05:00
|
|
|
@suggestions = AccountSuggestions.new(current_account)
|
2021-04-12 06:37:14 -04:00
|
|
|
end
|
|
|
|
end
|