1
0
mirror of https://github.com/mastodon/mastodon synced 2025-01-10 20:03:22 +09:00

[WiP] Fix some hardcoded routes in ActivityPub URI generation

This commit is contained in:
Claire 2024-10-31 17:43:58 +01:00
parent cbddbccf3e
commit 7c9cdd5894
3 changed files with 11 additions and 5 deletions

View File

@ -86,6 +86,12 @@ class ActivityPub::TagManager
account_status_shares_url(target.account, target)
end
def following_uri_for(target, ...)
raise ArgumentError, 'target must be a local account' unless target.local?
account_following_index_url(target, ...)
end
def followers_uri_for(target)
target.local? ? account_followers_url(target) : target.followers_url.presence
end
@ -99,7 +105,7 @@ class ActivityPub::TagManager
when 'public'
[COLLECTIONS[:public]]
when 'unlisted', 'private'
[account_followers_url(status.account)]
[followers_uri_for(status.account)]
when 'direct', 'limited'
if status.account.silenced?
# Only notify followers if the account is locally silenced
@ -133,7 +139,7 @@ class ActivityPub::TagManager
case status.visibility
when 'public'
cc << account_followers_url(status.account)
cc << followers_uri_for(status.account)
when 'unlisted'
cc << COLLECTIONS[:public]
end

View File

@ -44,7 +44,7 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer
delegate :suspended?, :instance_actor?, to: :object
def id
object.instance_actor? ? instance_actor_url : account_url(object)
ActivityPub::TagManager.instance.uri_for(object)
end
def type

View File

@ -13,7 +13,7 @@ class WebfingerSerializer < ActiveModel::Serializer
if object.instance_actor?
[instance_actor_url]
else
[short_account_url(object), account_url(object)]
[short_account_url(object), ActivityPub::TagManager.instance.uri_for(object)]
end
end
@ -43,6 +43,6 @@ class WebfingerSerializer < ActiveModel::Serializer
end
def self_href
object.instance_actor? ? instance_actor_url : account_url(object)
ActivityPub::TagManager.instance.uri_for(object)
end
end