mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-23 04:02:07 +01:00
[WiP] Move ActivityPub URI generation to ActivityPub::TagManager
This commit is contained in:
parent
5a472953e6
commit
b8eadc7996
7 changed files with 34 additions and 18 deletions
|
@ -49,7 +49,7 @@ class ActivityPub::CollectionsController < ActivityPub::BaseController
|
||||||
|
|
||||||
def collection_presenter
|
def collection_presenter
|
||||||
ActivityPub::CollectionPresenter.new(
|
ActivityPub::CollectionPresenter.new(
|
||||||
id: account_collection_url(@account, params[:id]),
|
id: ActivityPub::TagManager.instance.collection_uri_for(@account, params[:id]),
|
||||||
type: @type,
|
type: @type,
|
||||||
size: @size,
|
size: @size,
|
||||||
items: @items
|
items: @items
|
||||||
|
|
|
@ -41,12 +41,8 @@ class ActivityPub::OutboxesController < ActivityPub::BaseController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def outbox_url(**)
|
def outbox_url(...)
|
||||||
if params[:account_username].present?
|
ActivityPub::TagManager.instance.outbox_uri_for(@account, ...)
|
||||||
account_outbox_url(@account, **)
|
|
||||||
else
|
|
||||||
instance_actor_outbox_url(**)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def next_page
|
def next_page
|
||||||
|
|
|
@ -46,7 +46,7 @@ class FollowerAccountsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def page_url(page)
|
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
|
end
|
||||||
|
|
||||||
def next_page_url
|
def next_page_url
|
||||||
|
|
|
@ -86,8 +86,28 @@ class ActivityPub::TagManager
|
||||||
account_status_shares_url(target.account, target)
|
account_status_shares_url(target.account, target)
|
||||||
end
|
end
|
||||||
|
|
||||||
def followers_uri_for(target)
|
def followers_uri_for(target, ...)
|
||||||
target.local? ? account_followers_url(target) : target.followers_url.presence
|
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
|
end
|
||||||
|
|
||||||
# Primary audience of a status
|
# Primary audience of a status
|
||||||
|
|
|
@ -60,27 +60,27 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def following
|
def following
|
||||||
account_following_index_url(object)
|
ActivityPub::TagManager.instance.following_uri_for(object)
|
||||||
end
|
end
|
||||||
|
|
||||||
def followers
|
def followers
|
||||||
account_followers_url(object)
|
ActivityPub::TagManager.instance.followers_uri_for(object)
|
||||||
end
|
end
|
||||||
|
|
||||||
def inbox
|
def inbox
|
||||||
object.instance_actor? ? instance_actor_inbox_url : account_inbox_url(object)
|
ActivityPub::TagManager.instance.inbox_uri_for(object)
|
||||||
end
|
end
|
||||||
|
|
||||||
def outbox
|
def outbox
|
||||||
object.instance_actor? ? instance_actor_outbox_url : account_outbox_url(object)
|
ActivityPub::TagManager.instance.outbox_uri_for(object)
|
||||||
end
|
end
|
||||||
|
|
||||||
def featured
|
def featured
|
||||||
account_collection_url(object, :featured)
|
ActivityPub::TagManager.instance.collection_uri_for(object, :featured)
|
||||||
end
|
end
|
||||||
|
|
||||||
def featured_tags
|
def featured_tags
|
||||||
account_collection_url(object, :tags)
|
ActivityPub::TagManager.instance.collection_uri_for(object, :tags)
|
||||||
end
|
end
|
||||||
|
|
||||||
def endpoints
|
def endpoints
|
||||||
|
|
|
@ -38,6 +38,6 @@ class ActivityPub::AddSerializer < ActivityPub::Serializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def target
|
def target
|
||||||
account_collection_url(object.account, :featured)
|
ActivityPub::TagManager.instance.collection_uri_for(object.account, :featured)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -38,6 +38,6 @@ class ActivityPub::RemoveSerializer < ActivityPub::Serializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def target
|
def target
|
||||||
account_collection_url(object.account, :featured)
|
ActivityPub::TagManager.instance.collection_uri_for(object.account, :featured)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue