0
0
Fork 0

Change ActivityPub path generation to all happen in ActivityPub::TagManager (#33527)

This commit is contained in:
Claire 2025-01-13 10:39:05 +01:00 committed by GitHub
parent 53885b0fdb
commit d517fa5ab7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 82 additions and 27 deletions

View file

@ -86,8 +86,34 @@ 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 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, ...)
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
@ -99,7 +125,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 +159,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