From 8724094ed0e531f4435bf2784c9c1b7176acd764 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 29 Dec 2016 17:23:27 +0100 Subject: [PATCH] Support remote follow request providing URL instead of acct --- app/assets/stylesheets/accounts.scss | 4 ++++ .../authorize_follow_controller.rb | 19 ++++++++++++++++++- app/views/authorize_follow/new.html.haml | 3 ++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/accounts.scss b/app/assets/stylesheets/accounts.scss index 5d0963307a..748bb82241 100644 --- a/app/assets/stylesheets/accounts.scss +++ b/app/assets/stylesheets/accounts.scss @@ -337,6 +337,10 @@ overflow: hidden; margin-bottom: 15px; + &:last-child { + margin-bottom: 0; + } + & > div { float: left; margin-right: 10px; diff --git a/app/controllers/authorize_follow_controller.rb b/app/controllers/authorize_follow_controller.rb index a276250a47..ca72c9691e 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 diff --git a/app/views/authorize_follow/new.html.haml b/app/views/authorize_follow/new.html.haml index 7368b834a2..44bf575ff4 100644 --- a/app/views/authorize_follow/new.html.haml +++ b/app/views/authorize_follow/new.html.haml @@ -14,7 +14,8 @@ %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