mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-22 12:55:56 +01:00
Rename /u/:user_id
to /ap/users/:user_id
and /s/:id
to /ap/statuses/:id
This commit is contained in:
parent
6fe4064b3f
commit
185c62138b
3 changed files with 24 additions and 22 deletions
|
@ -41,15 +41,15 @@ class ActivityPub::TagManager
|
||||||
if target.instance_actor?
|
if target.instance_actor?
|
||||||
instance_actor_url
|
instance_actor_url
|
||||||
elsif target.numeric_ap_id?
|
elsif target.numeric_ap_id?
|
||||||
numeric_account_url(target.id)
|
ap_account_url(target.id)
|
||||||
else
|
else
|
||||||
account_url(target)
|
account_url(target)
|
||||||
end
|
end
|
||||||
when :note, :comment, :activity
|
when :note, :comment, :activity
|
||||||
if target.account.numeric_ap_id?
|
if target.account.numeric_ap_id?
|
||||||
return activity_numeric_status_url(target.account, target) if target.reblog?
|
return activity_ap_status_url(target.account, target) if target.reblog?
|
||||||
|
|
||||||
numeric_status_url(target)
|
ap_status_url(target)
|
||||||
else
|
else
|
||||||
return activity_account_status_url(target.account, target) if target.reblog?
|
return activity_account_status_url(target.account, target) if target.reblog?
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ class ActivityPub::TagManager
|
||||||
end
|
end
|
||||||
|
|
||||||
def uri_for_account_id(id)
|
def uri_for_account_id(id)
|
||||||
numeric_account_url(id: id)
|
ap_account_url(id: id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_uri_for(_target)
|
def generate_uri_for(_target)
|
||||||
|
@ -81,43 +81,43 @@ class ActivityPub::TagManager
|
||||||
def activity_uri_for(target)
|
def activity_uri_for(target)
|
||||||
raise ArgumentError, 'target must be a local activity' unless %i(note comment activity).include?(target.object_type) && target.local?
|
raise ArgumentError, 'target must be a local activity' unless %i(note comment activity).include?(target.object_type) && target.local?
|
||||||
|
|
||||||
target.account.numeric_ap_id? ? activity_numeric_status_url(target) : activity_account_status_url(target.account, target)
|
target.account.numeric_ap_id? ? activity_ap_status_url(target) : activity_account_status_url(target.account, target)
|
||||||
end
|
end
|
||||||
|
|
||||||
def replies_uri_for(target, page_params = nil)
|
def replies_uri_for(target, page_params = nil)
|
||||||
raise ArgumentError, 'target must be a local activity' unless %i(note comment activity).include?(target.object_type) && target.local?
|
raise ArgumentError, 'target must be a local activity' unless %i(note comment activity).include?(target.object_type) && target.local?
|
||||||
|
|
||||||
target.account.numeric_ap_id? ? numeric_status_replies_url(target, page_params) : account_status_replies_url(target.account, target, page_params)
|
target.account.numeric_ap_id? ? ap_status_replies_url(target, page_params) : account_status_replies_url(target.account, target, page_params)
|
||||||
end
|
end
|
||||||
|
|
||||||
def likes_uri_for(target)
|
def likes_uri_for(target)
|
||||||
raise ArgumentError, 'target must be a local activity' unless %i(note comment activity).include?(target.object_type) && target.local?
|
raise ArgumentError, 'target must be a local activity' unless %i(note comment activity).include?(target.object_type) && target.local?
|
||||||
|
|
||||||
target.account.numeric_ap_id? ? numeric_status_likes_url(target) : account_status_likes_url(target.account, target)
|
target.account.numeric_ap_id? ? ap_status_likes_url(target) : account_status_likes_url(target.account, target)
|
||||||
end
|
end
|
||||||
|
|
||||||
def shares_uri_for(target)
|
def shares_uri_for(target)
|
||||||
raise ArgumentError, 'target must be a local activity' unless %i(note comment activity).include?(target.object_type) && target.local?
|
raise ArgumentError, 'target must be a local activity' unless %i(note comment activity).include?(target.object_type) && target.local?
|
||||||
|
|
||||||
target.account.numeric_ap_id? ? numeric_status_shares_url(target) : account_status_shares_url(target.account, target)
|
target.account.numeric_ap_id? ? ap_status_shares_url(target) : account_status_shares_url(target.account, target)
|
||||||
end
|
end
|
||||||
|
|
||||||
def following_uri_for(target, ...)
|
def following_uri_for(target, ...)
|
||||||
raise ArgumentError, 'target must be a local account' unless target.local?
|
raise ArgumentError, 'target must be a local account' unless target.local?
|
||||||
|
|
||||||
target.numeric_ap_id? ? numeric_account_following_index_url(target.id, ...) : account_following_index_url(target, ...)
|
target.numeric_ap_id? ? ap_account_following_index_url(target.id, ...) : account_following_index_url(target, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
def followers_uri_for(target, ...)
|
def followers_uri_for(target, ...)
|
||||||
return target.followers_url.presence unless target.local?
|
return target.followers_url.presence unless target.local?
|
||||||
|
|
||||||
target.numeric_ap_id? ? numeric_account_followers_url(target.id, ...) : account_followers_url(target, ...)
|
target.numeric_ap_id? ? ap_account_followers_url(target.id, ...) : account_followers_url(target, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
def collection_uri_for(target, ...)
|
def collection_uri_for(target, ...)
|
||||||
raise ArgumentError, 'target must be a local account' unless target.local?
|
raise ArgumentError, 'target must be a local account' unless target.local?
|
||||||
|
|
||||||
target.numeric_ap_id? ? numeric_account_collection_url(target.id, ...) : account_collection_url(target, ...)
|
target.numeric_ap_id? ? ap_account_collection_url(target.id, ...) : account_collection_url(target, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
def inbox_uri_for(target)
|
def inbox_uri_for(target)
|
||||||
|
@ -126,7 +126,7 @@ class ActivityPub::TagManager
|
||||||
if target.instance_actor?
|
if target.instance_actor?
|
||||||
instance_actor_inbox_url
|
instance_actor_inbox_url
|
||||||
elsif target.numeric_ap_id?
|
elsif target.numeric_ap_id?
|
||||||
numeric_account_inbox_url(target.id)
|
ap_account_inbox_url(target.id)
|
||||||
else
|
else
|
||||||
account_inbox_url(target)
|
account_inbox_url(target)
|
||||||
end
|
end
|
||||||
|
@ -138,7 +138,7 @@ class ActivityPub::TagManager
|
||||||
if target.instance_actor?
|
if target.instance_actor?
|
||||||
instance_actor_outbox_url(...)
|
instance_actor_outbox_url(...)
|
||||||
elsif target.numeric_ap_id?
|
elsif target.numeric_ap_id?
|
||||||
numeric_account_outbox_url(target.id, ...)
|
ap_account_outbox_url(target.id, ...)
|
||||||
else
|
else
|
||||||
account_outbox_url(target, ...)
|
account_outbox_url(target, ...)
|
||||||
end
|
end
|
||||||
|
|
|
@ -119,16 +119,18 @@ Rails.application.routes.draw do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :accounts, path: 'u', only: [:show], param: :id, as: :numeric_account, concerns: :account_resources
|
scope path: 'ap', as: 'ap' do
|
||||||
|
resources :accounts, path: 'users', only: [:show], param: :id, concerns: :account_resources
|
||||||
|
|
||||||
resources :statuses, path: 's', only: [:show], as: :numeric_status do
|
resources :statuses, module: :activitypub, only: [:show] do
|
||||||
member do
|
member do
|
||||||
get :activity
|
get :activity
|
||||||
|
end
|
||||||
|
|
||||||
|
resources :replies, only: [:index]
|
||||||
|
resources :likes, only: [:index]
|
||||||
|
resources :shares, only: [:index]
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :replies, only: [:index], module: :activitypub
|
|
||||||
resources :likes, only: [:index], module: :activitypub
|
|
||||||
resources :shares, only: [:index], module: :activitypub
|
|
||||||
end
|
end
|
||||||
|
|
||||||
resource :inbox, only: [:create], module: :activitypub
|
resource :inbox, only: [:create], module: :activitypub
|
||||||
|
|
|
@ -7,7 +7,7 @@ RSpec.describe 'Accounts show response' do
|
||||||
|
|
||||||
context 'with numeric-based identifiers' do
|
context 'with numeric-based identifiers' do
|
||||||
it 'returns http success' do
|
it 'returns http success' do
|
||||||
get "/u/#{account.id}"
|
get "/ap/users/#{account.id}"
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(200)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue