lookup_controller.rb 551 B

12345678910111213141516171819
  1. # frozen_string_literal: true
  2. class Api::V1::Accounts::LookupController < Api::BaseController
  3. before_action -> { authorize_if_got_token! :read, :'read:accounts' }
  4. before_action :set_account
  5. def show
  6. cache_if_unauthenticated!
  7. render json: @account, serializer: REST::AccountSerializer
  8. end
  9. private
  10. def set_account
  11. @account = ResolveAccountService.new.call(params[:acct], skip_webfinger: true) || raise(ActiveRecord::RecordNotFound)
  12. rescue Addressable::URI::InvalidURIError
  13. raise(ActiveRecord::RecordNotFound)
  14. end
  15. end