forked from mastodon/mastodon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to use remote follow function on other sites
- Loading branch information
Showing
18 changed files
with
166 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module AuthorizeFollowHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.form-container | ||
.flash-message#error_explanation | ||
= t('authorize_follow.error') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
- content_for :page_title do | ||
= t('authorize_follow.title', acct: @account.acct) | ||
|
||
.form-container | ||
.follow-prompt | ||
%h2= t('authorize_follow.prompt_html', self: current_account.username) | ||
|
||
.account-card | ||
.detailed-status__display-name | ||
%div | ||
= image_tag @account.avatar.url(:original), alt: '', width: 48, height: 48, class: 'avatar' | ||
|
||
%span.display-name | ||
%strong= display_name(@account) | ||
%span= "@#{@account.acct}" | ||
|
||
.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 | ||
= button_tag t('authorize_follow.follow'), type: :submit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.flash-message#error_explanation | ||
= @pre_auth.error_response.body[:error_description] | ||
.form-container | ||
.flash-message#error_explanation | ||
= @pre_auth.error_response.body[:error_description] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,26 @@ | ||
- content_for :page_title do | ||
= t('doorkeeper.authorizations.new.title') | ||
|
||
.oauth-prompt | ||
%h2= t('doorkeeper.authorizations.new.prompt', client_name: @pre_auth.client.name) | ||
.form-container | ||
.oauth-prompt | ||
%h2= t('doorkeeper.authorizations.new.prompt', client_name: @pre_auth.client.name) | ||
|
||
%p | ||
= t('doorkeeper.authorizations.new.able_to') | ||
= @pre_auth.scopes.map { |scope| t(scope, scope: [:doorkeeper, :scopes]) }.map { |s| "<strong>#{s}</strong>"}.to_sentence.html_safe | ||
%p | ||
= t('doorkeeper.authorizations.new.able_to') | ||
= @pre_auth.scopes.map { |scope| t(scope, scope: [:doorkeeper, :scopes]) }.map { |s| "<strong>#{s}</strong>"}.to_sentence.html_safe | ||
|
||
= form_tag oauth_authorization_path, method: :post, class: 'simple_form' do | ||
= hidden_field_tag :client_id, @pre_auth.client.uid | ||
= hidden_field_tag :redirect_uri, @pre_auth.redirect_uri | ||
= hidden_field_tag :state, @pre_auth.state | ||
= hidden_field_tag :response_type, @pre_auth.response_type | ||
= hidden_field_tag :scope, @pre_auth.scope | ||
= button_tag t('doorkeeper.authorizations.buttons.authorize'), type: :submit | ||
= form_tag oauth_authorization_path, method: :post, class: 'simple_form' do | ||
= hidden_field_tag :client_id, @pre_auth.client.uid | ||
= hidden_field_tag :redirect_uri, @pre_auth.redirect_uri | ||
= hidden_field_tag :state, @pre_auth.state | ||
= hidden_field_tag :response_type, @pre_auth.response_type | ||
= hidden_field_tag :scope, @pre_auth.scope | ||
= button_tag t('doorkeeper.authorizations.buttons.authorize'), type: :submit | ||
|
||
= form_tag oauth_authorization_path, method: :delete, class: 'simple_form' do | ||
= hidden_field_tag :client_id, @pre_auth.client.uid | ||
= hidden_field_tag :redirect_uri, @pre_auth.redirect_uri | ||
= hidden_field_tag :state, @pre_auth.state | ||
= hidden_field_tag :response_type, @pre_auth.response_type | ||
= hidden_field_tag :scope, @pre_auth.scope | ||
= button_tag t('doorkeeper.authorizations.buttons.deny'), type: :submit, class: 'negative' | ||
= form_tag oauth_authorization_path, method: :delete, class: 'simple_form' do | ||
= hidden_field_tag :client_id, @pre_auth.client.uid | ||
= hidden_field_tag :redirect_uri, @pre_auth.redirect_uri | ||
= hidden_field_tag :state, @pre_auth.state | ||
= hidden_field_tag :response_type, @pre_auth.response_type | ||
= hidden_field_tag :scope, @pre_auth.scope | ||
= button_tag t('doorkeeper.authorizations.buttons.deny'), type: :submit, class: 'negative' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.flash-message | ||
%code= params[:code] | ||
.form-container | ||
.flash-message | ||
%code= params[:code] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe AuthorizeFollowController, type: :controller do | ||
describe 'GET #new' | ||
describe 'POST #create' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe AuthorizeFollowHelper, type: :helper do | ||
|
||
end |