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
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
%strong= display_name(@account)
%span= "@#{@account.acct}"
- .account__header__content= Formatter.instance.simplified_format(@account)
+ - unless @account.note.blank?
+ .account__header__content= Formatter.instance.simplified_format(@account)
= form_tag authorize_follow_path, method: :post, class: 'simple_form' do
= hidden_field_tag :acct, @account.acct