From 0618f09939b7afc607bcd983139b91e056debe4d Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Wed, 26 Apr 2017 18:19:53 -0400 Subject: Add spec coverage and refactor authorize_follows controller (#2505) --- app/controllers/authorize_follow_controller.rb | 45 -------------------------- 1 file changed, 45 deletions(-) delete mode 100644 app/controllers/authorize_follow_controller.rb (limited to 'app/controllers/authorize_follow_controller.rb') diff --git a/app/controllers/authorize_follow_controller.rb b/app/controllers/authorize_follow_controller.rb deleted file mode 100644 index 9b28a9455..000000000 --- a/app/controllers/authorize_follow_controller.rb +++ /dev/null @@ -1,45 +0,0 @@ -# frozen_string_literal: true - -class AuthorizeFollowController < ApplicationController - layout 'public' - - before_action :authenticate_user! - - def new - uri = Addressable::URI.parse(acct_param).normalize - - 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 - - def create - @account = FollowService.new.call(current_account, acct_param).try(:target_account) - - if @account.nil? - render :error - else - redirect_to web_url("accounts/#{@account.id}") - end - rescue ActiveRecord::RecordNotFound, Mastodon::NotPermittedError - render :error - end - - private - - def set_account_from_url - @account = FetchRemoteAccountService.new.call(acct_param) - end - - def set_account_from_acct - @account = FollowRemoteAccountService.new.call(acct_param) - end - - def acct_param - params[:acct].gsub(/\Aacct:/, '') - end -end -- cgit