diff --git a/app/controllers/activitypub/collections_controller.rb b/app/controllers/activitypub/collections_controller.rb index ab1b98e646..c80db3500d 100644 --- a/app/controllers/activitypub/collections_controller.rb +++ b/app/controllers/activitypub/collections_controller.rb @@ -49,7 +49,7 @@ class ActivityPub::CollectionsController < ActivityPub::BaseController def collection_presenter ActivityPub::CollectionPresenter.new( - id: account_collection_url(@account, params[:id]), + id: ActivityPub::TagManager.instance.collection_uri_for(@account, params[:id]), type: @type, size: @size, items: @items diff --git a/app/controllers/activitypub/outboxes_controller.rb b/app/controllers/activitypub/outboxes_controller.rb index 0c995edbf8..a9476b806f 100644 --- a/app/controllers/activitypub/outboxes_controller.rb +++ b/app/controllers/activitypub/outboxes_controller.rb @@ -41,12 +41,8 @@ class ActivityPub::OutboxesController < ActivityPub::BaseController end end - def outbox_url(**) - if params[:account_username].present? - account_outbox_url(@account, **) - else - instance_actor_outbox_url(**) - end + def outbox_url(...) + ActivityPub::TagManager.instance.outbox_uri_for(@account, ...) end def next_page diff --git a/app/controllers/follower_accounts_controller.rb b/app/controllers/follower_accounts_controller.rb index 5effd9495e..f4c7b37088 100644 --- a/app/controllers/follower_accounts_controller.rb +++ b/app/controllers/follower_accounts_controller.rb @@ -46,7 +46,7 @@ class FollowerAccountsController < ApplicationController end def page_url(page) - account_followers_url(@account, page: page) unless page.nil? + ActivityPub::TagManager.instance.followers_uri_for(@account, page: page) unless page.nil? end def next_page_url diff --git a/app/lib/activitypub/tag_manager.rb b/app/lib/activitypub/tag_manager.rb index f7f2d18618..c899f230a2 100644 --- a/app/lib/activitypub/tag_manager.rb +++ b/app/lib/activitypub/tag_manager.rb @@ -86,8 +86,28 @@ class ActivityPub::TagManager account_status_shares_url(target.account, target) end - def followers_uri_for(target) - target.local? ? account_followers_url(target) : target.followers_url.presence + def followers_uri_for(target, ...) + return target.followers_url.presence unless target.local? + + account_followers_url(target, ...) + end + + def collection_uri_for(target, ...) + raise NotImplementedError unless target.local? + + account_collection_url(target, ...) + end + + def inbox_uri_for(target) + raise NotImplementedError unless target.local? + + target.instance_actor? ? instance_actor_inbox_url : account_inbox_url(target) + end + + def outbox_uri_for(target, ...) + raise NotImplementedError unless target.local? + + target.instance_actor? ? instance_actor_outbox_url(...) : account_outbox_url(target, ...) end # Primary audience of a status diff --git a/app/serializers/activitypub/actor_serializer.rb b/app/serializers/activitypub/actor_serializer.rb index 02d54ca9f3..ed90fa428f 100644 --- a/app/serializers/activitypub/actor_serializer.rb +++ b/app/serializers/activitypub/actor_serializer.rb @@ -60,27 +60,27 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer end def following - account_following_index_url(object) + ActivityPub::TagManager.instance.following_uri_for(object) end def followers - account_followers_url(object) + ActivityPub::TagManager.instance.followers_uri_for(object) end def inbox - object.instance_actor? ? instance_actor_inbox_url : account_inbox_url(object) + ActivityPub::TagManager.instance.inbox_uri_for(object) end def outbox - object.instance_actor? ? instance_actor_outbox_url : account_outbox_url(object) + ActivityPub::TagManager.instance.outbox_uri_for(object) end def featured - account_collection_url(object, :featured) + ActivityPub::TagManager.instance.collection_uri_for(object, :featured) end def featured_tags - account_collection_url(object, :tags) + ActivityPub::TagManager.instance.collection_uri_for(object, :tags) end def endpoints diff --git a/app/serializers/activitypub/add_serializer.rb b/app/serializers/activitypub/add_serializer.rb index 436b05086f..640d774272 100644 --- a/app/serializers/activitypub/add_serializer.rb +++ b/app/serializers/activitypub/add_serializer.rb @@ -38,6 +38,6 @@ class ActivityPub::AddSerializer < ActivityPub::Serializer end def target - account_collection_url(object.account, :featured) + ActivityPub::TagManager.instance.collection_uri_for(object.account, :featured) end end diff --git a/app/serializers/activitypub/remove_serializer.rb b/app/serializers/activitypub/remove_serializer.rb index fb224f8a99..4f78804031 100644 --- a/app/serializers/activitypub/remove_serializer.rb +++ b/app/serializers/activitypub/remove_serializer.rb @@ -38,6 +38,6 @@ class ActivityPub::RemoveSerializer < ActivityPub::Serializer end def target - account_collection_url(object.account, :featured) + ActivityPub::TagManager.instance.collection_uri_for(object.account, :featured) end end