about summary refs log tree commit diff
path: root/app/controllers/authorize_follow_controller.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-12-29 17:23:27 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-12-29 17:23:27 +0100
commit8724094ed0e531f4435bf2784c9c1b7176acd764 (patch)
treef40d8c65f178c89030fdf9ec3351707b4723e712 /app/controllers/authorize_follow_controller.rb
parentd7dc84439c60069a0cb9eeca81dc61c297a8667b (diff)
Support remote follow request providing URL instead of acct
Diffstat (limited to 'app/controllers/authorize_follow_controller.rb')
-rw-r--r--app/controllers/authorize_follow_controller.rb19
1 files changed, 18 insertions, 1 deletions
diff --git a/app/controllers/authorize_follow_controller.rb b/app/controllers/authorize_follow_controller.rb
index a276250a4..ca72c9691 100644
--- a/app/controllers/authorize_follow_controller.rb
+++ b/app/controllers/authorize_follow_controller.rb
@@ -6,7 +6,14 @@ class AuthorizeFollowController < ApplicationController
   before_action :authenticate_user!
 
   def new
-    @account = FollowRemoteAccountService.new.call(params[:acct])
+    uri = Addressable::URI.parse(params[:acct])
+
+    if uri.path && %w(http https).include?(uri.scheme)
+      set_account_from_url
+    else
+      set_account_from_acct
+    end
+
     render :error if @account.nil?
   end
 
@@ -21,4 +28,14 @@ class AuthorizeFollowController < ApplicationController
   rescue ActiveRecord::RecordNotFound, Mastodon::NotPermitted
     render :error
   end
+
+  private
+
+  def set_account_from_url
+    @account = FetchRemoteAccountService.new.call(params[:acct])
+  end
+
+  def set_account_from_acct
+    @account = FollowRemoteAccountService.new.call(params[:acct])
+  end
 end