From 6fe4064b3f75a0676b097113753416f4ead2cf74 Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 18 Dec 2024 10:17:53 +0100 Subject: [PATCH] [Broken WiP] Use `/s/:id` instead of `/u/:account_id/statuses/:id` for statuses in new scheme --- app/lib/activitypub/tag_manager.rb | 12 +++++----- config/routes.rb | 35 ++++++++++++++++++++---------- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/app/lib/activitypub/tag_manager.rb b/app/lib/activitypub/tag_manager.rb index 536b3fadd4..c5a0252069 100644 --- a/app/lib/activitypub/tag_manager.rb +++ b/app/lib/activitypub/tag_manager.rb @@ -47,9 +47,9 @@ class ActivityPub::TagManager end when :note, :comment, :activity if target.account.numeric_ap_id? - return activity_numeric_account_status_url(target.account, target) if target.reblog? + return activity_numeric_status_url(target.account, target) if target.reblog? - numeric_account_status_url(target.account.id, target) + numeric_status_url(target) else return activity_account_status_url(target.account, target) if target.reblog? @@ -81,25 +81,25 @@ class ActivityPub::TagManager def activity_uri_for(target) 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_account_status_url(target.account.id, target) : activity_account_status_url(target.account, target) + target.account.numeric_ap_id? ? activity_numeric_status_url(target) : activity_account_status_url(target.account, target) end 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? - target.account.numeric_ap_id? ? numeric_account_status_replies_url(target.account.id, target, page_params) : account_status_replies_url(target.account, target, page_params) + target.account.numeric_ap_id? ? numeric_status_replies_url(target, page_params) : account_status_replies_url(target.account, target, page_params) end def likes_uri_for(target) 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_account_status_likes_url(target.account.id, target) : account_status_likes_url(target.account, target) + target.account.numeric_ap_id? ? numeric_status_likes_url(target) : account_status_likes_url(target.account, target) end def shares_uri_for(target) 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_account_status_shares_url(target.account.id, target) : account_status_shares_url(target.account, target) + target.account.numeric_ap_id? ? numeric_status_shares_url(target) : account_status_shares_url(target.account, target) end def following_uri_for(target, ...) diff --git a/config/routes.rb b/config/routes.rb index 2e6d86033b..37b9e20002 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -95,17 +95,6 @@ Rails.application.routes.draw do get '/authorize_follow', to: redirect { |_, request| "/authorize_interaction?#{request.params.to_query}" } concern :account_resources do - resources :statuses, only: [:show] do - member do - get :activity - get :embed - end - - resources :replies, only: [:index], module: :activitypub - resources :likes, only: [:index], module: :activitypub - resources :shares, only: [:index], module: :activitypub - end - resources :followers, only: [:index], controller: :follower_accounts resources :following, only: [:index], controller: :following_accounts @@ -117,9 +106,31 @@ Rails.application.routes.draw do end end - resources :accounts, path: 'users', only: [:show], param: :username, concerns: :account_resources + resources :accounts, path: 'users', only: [:show], param: :username, concerns: :account_resources do + resources :statuses, only: [:show] do + member do + get :activity + get :embed + end + + resources :replies, only: [:index], module: :activitypub + resources :likes, only: [:index], module: :activitypub + resources :shares, only: [:index], module: :activitypub + end + end + resources :accounts, path: 'u', only: [:show], param: :id, as: :numeric_account, concerns: :account_resources + resources :statuses, path: 's', only: [:show], as: :numeric_status do + member do + get :activity + end + + resources :replies, only: [:index], module: :activitypub + resources :likes, only: [:index], module: :activitypub + resources :shares, only: [:index], module: :activitypub + end + resource :inbox, only: [:create], module: :activitypub constraints(encoded_path: /%40.*/) do