about summary refs log tree commit diff
path: root/app/controllers
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2021-02-16 15:28:32 +0100
committerGitHub <noreply@github.com>2021-02-16 15:28:32 +0100
commite31ed2748597c9f31afba87dcdf47082949f0f23 (patch)
tree4260b4312b37eefd51e13e78e9d6f5fe296057fe /app/controllers
parent3f8523130da1029ba64d00c03360a2c15f85d9d6 (diff)
Add `GET /api/v1/accounts/lookup` REST API (#15740)
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/api/v1/accounts/lookup_controller.rb16
1 files changed, 16 insertions, 0 deletions
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