about summary refs log tree commit diff
path: root/app/controllers
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-12-29 16:54:54 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-12-29 16:54:54 +0100
commitd7dc84439c60069a0cb9eeca81dc61c297a8667b (patch)
tree167ee6db4fdc7008e2e517a0e983edb9721f4a7a /app/controllers
parent8b94d283fb45f054ee5193b0cec8586461d636b1 (diff)
Add ability to use remote follow function on other sites
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/authorize_follow_controller.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/app/controllers/authorize_follow_controller.rb b/app/controllers/authorize_follow_controller.rb
new file mode 100644
index 000000000..a276250a4
--- /dev/null
+++ b/app/controllers/authorize_follow_controller.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+class AuthorizeFollowController < ApplicationController
+  layout 'public'
+
+  before_action :authenticate_user!
+
+  def new
+    @account = FollowRemoteAccountService.new.call(params[:acct])
+    render :error if @account.nil?
+  end
+
+  def create
+    @account = FollowService.new.call(current_account, params[:acct]).try(:target_account)
+
+    if @account.nil?
+      render :error
+    else
+      redirect_to web_url("accounts/#{@account.id}")
+    end
+  rescue ActiveRecord::RecordNotFound, Mastodon::NotPermitted
+    render :error
+  end
+end