about summary refs log tree commit diff
path: root/app/controllers/authorize_follow_controller.rb
blob: a276250a47e13864a09e77b451ac8c61ceb96e68 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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