diff --git a/app/controllers/api/activitypub/activities_controller.rb b/app/controllers/api/activitypub/activities_controller.rb index 740c8589a7b2853f68199c3635d1e4b201cbe4db..a880ee92f27803fc9c468d0e65005ef60a7e3545 100644 --- a/app/controllers/api/activitypub/activities_controller.rb +++ b/app/controllers/api/activitypub/activities_controller.rb @@ -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] diff --git a/app/controllers/api/activitypub/notes_controller.rb b/app/controllers/api/activitypub/notes_controller.rb index 783c1c4edd43c4dad1d4fc45d3155b4c47f3c62a..96652b8791cf7fd6bfb582ce54a92e7446779470 100644 --- a/app/controllers/api/activitypub/notes_controller.rb +++ b/app/controllers/api/activitypub/notes_controller.rb @@ -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 diff --git a/app/controllers/api/activitypub/outbox_controller.rb b/app/controllers/api/activitypub/outbox_controller.rb index 0738d7dee5ae3efc55efa8704fd35b0d437311ee..1af04cb54fe6534bd7fd78d5ba59da4be616210b 100644 --- a/app/controllers/api/activitypub/outbox_controller.rb +++ b/app/controllers/api/activitypub/outbox_controller.rb @@ -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 diff --git a/app/controllers/authorize_follows_controller.rb b/app/controllers/authorize_follows_controller.rb index b15883d58351d8936368288e938d14cae7846445..da4ef022a0bbd6ee34494761d871f5096fae080a 100644 --- a/app/controllers/authorize_follows_controller.rb +++ b/app/controllers/authorize_follows_controller.rb @@ -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? diff --git a/app/services/account_search_service.rb b/app/services/account_search_service.rb index 2b77ad7c6ed373f43abc4f16ef28666bd8ef3d7c..c266494f00f878107a62054afa0cf15b04e54c02 100644 --- a/app/services/account_search_service.rb +++ b/app/services/account_search_service.rb @@ -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 diff --git a/app/services/concerns/author_extractor.rb b/app/services/concerns/author_extractor.rb index ae32eebbb586c86405a87f3356e36c04e47dc333..00fe1c66393a0b88b1c1fedc129dc12ae1f05b7d 100644 --- a/app/services/concerns/author_extractor.rb +++ b/app/services/concerns/author_extractor.rb @@ -18,6 +18,6 @@ module AuthorExtractor acct = "#{username}@#{domain}" end - FollowRemoteAccountService.new.call(acct, update_profile) + ResolveRemoteAccountService.new.call(acct, update_profile) end end diff --git a/app/services/follow_service.rb b/app/services/follow_service.rb index 4de75e98d736a7002c5be57b93e07945304588b4..e54ff7d0f5c9e0c0356c419f8a9edc0e536b351d 100644 --- a/app/services/follow_service.rb +++ b/app/services/follow_service.rb @@ -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) diff --git a/app/services/process_mentions_service.rb b/app/services/process_mentions_service.rb index aa0a4d71bbc8c2e7d4ea2571d3e4b83ebf602fe6..438033d22b34c116fdc70d56b843c3daaca7b7dc 100644 --- a/app/services/process_mentions_service.rb +++ b/app/services/process_mentions_service.rb @@ -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 diff --git a/app/services/follow_remote_account_service.rb b/app/services/resolve_remote_account_service.rb similarity index 98% rename from app/services/follow_remote_account_service.rb rename to app/services/resolve_remote_account_service.rb index 30ba7bc75abb5a8b5ac1cfd3f7f10a7525c4fe8f..362d0df98b18488e6b72068dbd8e0e225d60811a 100644 --- a/app/services/follow_remote_account_service.rb +++ b/app/services/resolve_remote_account_service.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class FollowRemoteAccountService < BaseService +class ResolveRemoteAccountService < BaseService include OStatus2::MagicKey include HttpHelper diff --git a/app/views/activitypub/types/collection.activitystreams2.rabl b/app/views/activitypub/types/collection.activitystreams2.rabl index d3f8ddcac1d27926038abd3e38e2d797d3509092..cc0e532b71e23ebf2fc8e8ccab8d1e4d5dd5ed09 100644 --- a/app/views/activitypub/types/collection.activitystreams2.rabl +++ b/app/views/activitypub/types/collection.activitystreams2.rabl @@ -1,3 +1,3 @@ extends 'activitypub/intransient.activitystreams2.rabl' -node(:type) { 'Collection' } +node(:type) { 'Collection' } diff --git a/app/views/activitypub/types/ordered_collection_page.activitystreams2.rabl b/app/views/activitypub/types/ordered_collection_page.activitystreams2.rabl index c821fa9288d618ceaec92495be5528fbe73eb9b0..9937d11e9cbec61c8b16c9c89857114c969c0de4 100644 --- a/app/views/activitypub/types/ordered_collection_page.activitystreams2.rabl +++ b/app/views/activitypub/types/ordered_collection_page.activitystreams2.rabl @@ -1,3 +1,3 @@ extends 'activitypub/types/ordered_collection.activitystreams2.rabl' -node(:type) { 'OrderedCollectionPage' } +node(:type) { 'OrderedCollectionPage' } diff --git a/app/workers/import_worker.rb b/app/workers/import_worker.rb index e93fa33cf98812fee698573327eaa9fa4b51c588..90a2262064a40954f8a47e99821f3f089be2b026 100644 --- a/app/workers/import_worker.rb +++ b/app/workers/import_worker.rb @@ -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 diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index b5e43e705f9ba5d4c8a3c8635ab96882598fae1d..a7b1ef690f2ef5564d42d526d0a2a8a408bc0b1d 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -13,4 +13,5 @@ ActiveSupport::Inflector.inflections(:en) do |inflect| inflect.acronym 'StatsD' inflect.acronym 'OEmbed' + inflect.acronym 'ActivityPub' end diff --git a/spec/controllers/api/activitypub/activities_controller_spec.rb b/spec/controllers/api/activitypub/activities_controller_spec.rb index 2c966a45a24e28b0ab93f48393b3a9a448ecd348..07df28ac2b6c1b934e2a250f9b78e8aa0ae1e6de 100644 --- a/spec/controllers/api/activitypub/activities_controller_spec.rb +++ b/spec/controllers/api/activitypub/activities_controller_spec.rb @@ -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')) } diff --git a/spec/controllers/api/activitypub/notes_controller_spec.rb b/spec/controllers/api/activitypub/notes_controller_spec.rb index 39ddec03e28284c3232bd5f65e2282c986bffb50..a0f05dc65932ea0965b354cb3436eca26a7f5c67 100644 --- a/spec/controllers/api/activitypub/notes_controller_spec.rb +++ b/spec/controllers/api/activitypub/notes_controller_spec.rb @@ -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')) } diff --git a/spec/controllers/api/activitypub/outbox_controller_spec.rb b/spec/controllers/api/activitypub/outbox_controller_spec.rb index 99797c582df671a2b889aaf222179a83062d74b8..049cf451d712a0c6c86f202f68a328c446ca36f4 100644 --- a/spec/controllers/api/activitypub/outbox_controller_spec.rb +++ b/spec/controllers/api/activitypub/outbox_controller_spec.rb @@ -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')) } diff --git a/spec/controllers/authorize_follows_controller_spec.rb b/spec/controllers/authorize_follows_controller_spec.rb index 1bc4eb6b776f3de67b0433384e9592803ddc591e..b801aa661748854aef28e8f2e54e52c91dbe81c0 100644 --- a/spec/controllers/authorize_follows_controller_spec.rb +++ b/spec/controllers/authorize_follows_controller_spec.rb @@ -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' } diff --git a/spec/controllers/settings/imports_controller_spec.rb b/spec/controllers/settings/imports_controller_spec.rb index 8bf6aec2b400977fbe241b1c491244d46614357d..4810be70159d43fee916f0151178e087229e78e2 100644 --- a/spec/controllers/settings/imports_controller_spec.rb +++ b/spec/controllers/settings/imports_controller_spec.rb @@ -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', diff --git a/spec/services/account_search_service_spec.rb b/spec/services/account_search_service_spec.rb index 697ac8f23c557e000a37c9abf26694b063161188..25bb56bca7d4d390142d532ce63d564bacff3ae7 100644 --- a/spec/services/account_search_service_spec.rb +++ b/spec/services/account_search_service_spec.rb @@ -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) diff --git a/spec/services/follow_remote_account_service_spec.rb b/spec/services/resolve_remote_account_service_spec.rb similarity index 97% rename from spec/services/follow_remote_account_service_spec.rb rename to spec/services/resolve_remote_account_service_spec.rb index 9ae9ff0ce5f3dd2999e510f664959e0a9b91540e..ad4d436ba31e9243a181303aa482351ed07806fd 100644 --- a/spec/services/follow_remote_account_service_spec.rb +++ b/spec/services/resolve_remote_account_service_spec.rb @@ -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'))