mirror of https://github.com/mastodon/mastodon
Rename FollowRemoteAccountService to ResolveRemoteAccountService (#3847)
Rename Activitypub to ActivityPub
This commit is contained in:
parent
aebebdc5d1
commit
f3be605286
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Api::Activitypub::ActivitiesController < Api::BaseController
|
||||
class Api::ActivityPub::ActivitiesController < Api::BaseController
|
||||
include Authorization
|
||||
|
||||
# before_action :set_follow, only: [:show_follow]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Api::Activitypub::NotesController < Api::BaseController
|
||||
class Api::ActivityPub::NotesController < Api::BaseController
|
||||
include Authorization
|
||||
|
||||
before_action :set_status
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Api::Activitypub::OutboxController < Api::BaseController
|
||||
class Api::ActivityPub::OutboxController < Api::BaseController
|
||||
before_action :set_account
|
||||
|
||||
respond_to :activitystreams2
|
||||
|
|
|
@ -40,7 +40,7 @@ class AuthorizeFollowsController < ApplicationController
|
|||
end
|
||||
|
||||
def account_from_remote_follow
|
||||
FollowRemoteAccountService.new.call(acct_without_prefix)
|
||||
ResolveRemoteAccountService.new.call(acct_without_prefix)
|
||||
end
|
||||
|
||||
def acct_param_is_url?
|
||||
|
|
|
@ -18,7 +18,7 @@ class AccountSearchService < BaseService
|
|||
return [] if query_blank_or_hashtag? || limit < 1
|
||||
|
||||
if resolving_non_matching_remote_account?
|
||||
[FollowRemoteAccountService.new.call("#{query_username}@#{query_domain}")]
|
||||
[ResolveRemoteAccountService.new.call("#{query_username}@#{query_domain}")]
|
||||
else
|
||||
search_results_and_exact_match.compact.uniq.slice(0, limit)
|
||||
end
|
||||
|
|
|
@ -18,6 +18,6 @@ module AuthorExtractor
|
|||
acct = "#{username}@#{domain}"
|
||||
end
|
||||
|
||||
FollowRemoteAccountService.new.call(acct, update_profile)
|
||||
ResolveRemoteAccountService.new.call(acct, update_profile)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,7 +7,7 @@ class FollowService < BaseService
|
|||
# @param [Account] source_account From which to follow
|
||||
# @param [String] uri User URI to follow in the form of username@domain
|
||||
def call(source_account, uri)
|
||||
target_account = FollowRemoteAccountService.new.call(uri)
|
||||
target_account = ResolveRemoteAccountService.new.call(uri)
|
||||
|
||||
raise ActiveRecord::RecordNotFound if target_account.nil? || target_account.id == source_account.id || target_account.suspended?
|
||||
raise Mastodon::NotPermittedError if target_account.blocking?(source_account) || source_account.blocking?(target_account)
|
||||
|
|
|
@ -41,6 +41,6 @@ class ProcessMentionsService < BaseService
|
|||
private
|
||||
|
||||
def follow_remote_account_service
|
||||
@follow_remote_account_service ||= FollowRemoteAccountService.new
|
||||
@follow_remote_account_service ||= ResolveRemoteAccountService.new
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class FollowRemoteAccountService < BaseService
|
||||
class ResolveRemoteAccountService < BaseService
|
||||
include OStatus2::MagicKey
|
||||
include HttpHelper
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
extends 'activitypub/intransient.activitystreams2.rabl'
|
||||
|
||||
node(:type) { 'Collection' }
|
||||
node(:type) { 'Collection' }
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
extends 'activitypub/types/ordered_collection.activitystreams2.rabl'
|
||||
|
||||
node(:type) { 'OrderedCollectionPage' }
|
||||
node(:type) { 'OrderedCollectionPage' }
|
||||
|
|
|
@ -41,7 +41,7 @@ class ImportWorker
|
|||
def process_mutes
|
||||
import_rows.each do |row|
|
||||
begin
|
||||
target_account = FollowRemoteAccountService.new.call(row.first)
|
||||
target_account = ResolveRemoteAccountService.new.call(row.first)
|
||||
next if target_account.nil?
|
||||
MuteService.new.call(from_account, target_account)
|
||||
rescue Goldfinger::Error, HTTP::Error, OpenSSL::SSL::SSLError
|
||||
|
@ -53,7 +53,7 @@ class ImportWorker
|
|||
def process_blocks
|
||||
import_rows.each do |row|
|
||||
begin
|
||||
target_account = FollowRemoteAccountService.new.call(row.first)
|
||||
target_account = ResolveRemoteAccountService.new.call(row.first)
|
||||
next if target_account.nil?
|
||||
BlockService.new.call(from_account, target_account)
|
||||
rescue Goldfinger::Error, HTTP::Error, OpenSSL::SSL::SSLError
|
||||
|
|
|
@ -13,4 +13,5 @@
|
|||
ActiveSupport::Inflector.inflections(:en) do |inflect|
|
||||
inflect.acronym 'StatsD'
|
||||
inflect.acronym 'OEmbed'
|
||||
inflect.acronym 'ActivityPub'
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Api::Activitypub::ActivitiesController, type: :controller do
|
||||
RSpec.describe Api::ActivityPub::ActivitiesController, type: :controller do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Api::Activitypub::NotesController, type: :controller do
|
||||
RSpec.describe Api::ActivityPub::NotesController, type: :controller do
|
||||
render_views
|
||||
|
||||
let(:user_alice) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Api::Activitypub::OutboxController, type: :controller do
|
||||
RSpec.describe Api::ActivityPub::OutboxController, type: :controller do
|
||||
render_views
|
||||
|
||||
let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
|
||||
|
|
|
@ -30,7 +30,7 @@ describe AuthorizeFollowsController do
|
|||
|
||||
it 'renders error when account cant be found' do
|
||||
service = double
|
||||
allow(FollowRemoteAccountService).to receive(:new).and_return(service)
|
||||
allow(ResolveRemoteAccountService).to receive(:new).and_return(service)
|
||||
allow(service).to receive(:call).with('missing@hostname').and_return(nil)
|
||||
|
||||
get :show, params: { acct: 'acct:missing@hostname' }
|
||||
|
@ -54,7 +54,7 @@ describe AuthorizeFollowsController do
|
|||
it 'sets account from acct uri' do
|
||||
account = Account.new
|
||||
service = double
|
||||
allow(FollowRemoteAccountService).to receive(:new).and_return(service)
|
||||
allow(ResolveRemoteAccountService).to receive(:new).and_return(service)
|
||||
allow(service).to receive(:call).with('found@hostname').and_return(account)
|
||||
|
||||
get :show, params: { acct: 'acct:found@hostname' }
|
||||
|
|
|
@ -17,7 +17,7 @@ RSpec.describe Settings::ImportsController, type: :controller do
|
|||
describe 'POST #create' do
|
||||
it 'redirects to settings path with successful following import' do
|
||||
service = double(call: nil)
|
||||
allow(FollowRemoteAccountService).to receive(:new).and_return(service)
|
||||
allow(ResolveRemoteAccountService).to receive(:new).and_return(service)
|
||||
post :create, params: {
|
||||
import: {
|
||||
type: 'following',
|
||||
|
@ -30,7 +30,7 @@ RSpec.describe Settings::ImportsController, type: :controller do
|
|||
|
||||
it 'redirects to settings path with successful blocking import' do
|
||||
service = double(call: nil)
|
||||
allow(FollowRemoteAccountService).to receive(:new).and_return(service)
|
||||
allow(ResolveRemoteAccountService).to receive(:new).and_return(service)
|
||||
post :create, params: {
|
||||
import: {
|
||||
type: 'blocking',
|
||||
|
|
|
@ -123,7 +123,7 @@ describe AccountSearchService do
|
|||
describe 'when there is a domain but no exact match' do
|
||||
it 'follows the remote account when resolve is true' do
|
||||
service = double(call: nil)
|
||||
allow(FollowRemoteAccountService).to receive(:new).and_return(service)
|
||||
allow(ResolveRemoteAccountService).to receive(:new).and_return(service)
|
||||
|
||||
results = subject.call('newuser@remote.com', 10, true)
|
||||
expect(service).to have_received(:call).with('newuser@remote.com')
|
||||
|
@ -131,7 +131,7 @@ describe AccountSearchService do
|
|||
|
||||
it 'does not follow the remote account when resolve is false' do
|
||||
service = double(call: nil)
|
||||
allow(FollowRemoteAccountService).to receive(:new).and_return(service)
|
||||
allow(ResolveRemoteAccountService).to receive(:new).and_return(service)
|
||||
|
||||
results = subject.call('newuser@remote.com', 10, false)
|
||||
expect(service).not_to have_received(:call)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe FollowRemoteAccountService do
|
||||
subject { FollowRemoteAccountService.new }
|
||||
RSpec.describe ResolveRemoteAccountService do
|
||||
subject { ResolveRemoteAccountService.new }
|
||||
|
||||
before do
|
||||
stub_request(:get, "https://quitter.no/.well-known/host-meta").to_return(request_fixture('.host-meta.txt'))
|
Loading…
Reference in New Issue