about summary refs log tree commit diff
path: root/app/controllers/api
diff options
context:
space:
mode:
authorStarfall <us@starfall.systems>2021-02-26 22:07:00 -0600
committerStarfall <us@starfall.systems>2021-02-26 22:07:00 -0600
commit033b1b5b900babc9b068ddad0ae644c5f15e9ffe (patch)
tree76a4d5f8890836e855cccdf4ad7d58fd9c0159ee /app/controllers/api
parent35f9f9565e142b8c8e7541549046bad679f1438d (diff)
parent4aa860b65bd796b09dc0ceffa1fdd7de31060a34 (diff)
Merge remote-tracking branch 'glitchsoc/main' into main
Diffstat (limited to 'app/controllers/api')
-rw-r--r--app/controllers/api/v1/accounts/lookup_controller.rb16
-rw-r--r--app/controllers/api/v1/instances/rules_controller.rb17
2 files changed, 33 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
diff --git a/app/controllers/api/v1/instances/rules_controller.rb b/app/controllers/api/v1/instances/rules_controller.rb
new file mode 100644
index 000000000..93cf3c759
--- /dev/null
+++ b/app/controllers/api/v1/instances/rules_controller.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class Api::V1::Instances::RulesController < Api::BaseController
+  skip_before_action :require_authenticated_user!, unless: :whitelist_mode?
+
+  before_action :set_rules
+
+  def index
+    render json: @rules, each_serializer: REST::RuleSerializer
+  end
+
+  private
+
+  def set_rules
+    @rules = Rule.ordered
+  end
+end