2021-04-12 03:37:14 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Api::V2::SuggestionsController < Api::BaseController
|
|
|
|
include Authorization
|
|
|
|
|
2023-12-19 02:59:43 -08:00
|
|
|
before_action -> { doorkeeper_authorize! :read, :'read:accounts' }, only: :index
|
|
|
|
before_action -> { doorkeeper_authorize! :write, :'write:accounts' }, except: :index
|
2021-04-12 03:37:14 -07:00
|
|
|
before_action :require_user!
|
|
|
|
before_action :set_suggestions
|
|
|
|
|
|
|
|
def index
|
2023-12-19 02:59:43 -08: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 03:37:14 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def set_suggestions
|
2023-12-19 02:59:43 -08:00
|
|
|
@suggestions = AccountSuggestions.new(current_account)
|
2021-04-12 03:37:14 -07:00
|
|
|
end
|
|
|
|
end
|