From e31ed2748597c9f31afba87dcdf47082949f0f23 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 16 Feb 2021 15:28:32 +0100 Subject: Add `GET /api/v1/accounts/lookup` REST API (#15740) --- app/controllers/api/v1/accounts/lookup_controller.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 app/controllers/api/v1/accounts/lookup_controller.rb (limited to 'app/controllers/api/v1/accounts') diff --git a/app/controllers/api/v1/accounts/lookup_controller.rb b/app/controllers/api/v1/accounts/lookup_controller.rb new file mode 100644 index 000000000..aee6be18a --- /dev/null +++ b/app/controllers/api/v1/accounts/lookup_controller.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class Api::V1::Accounts::LookupController < Api::BaseController + before_action -> { authorize_if_got_token! :read, :'read:accounts' } + before_action :set_account + + def show + render json: @account, serializer: REST::AccountSerializer + end + + private + + def set_account + @account = ResolveAccountService.new.call(params[:acct], skip_webfinger: true) || raise(ActiveRecord::RecordNotFound) + end +end -- cgit