diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index c3131edce9..efd0c92cef 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -71,6 +71,10 @@ class AccountsController < ApplicationController params[:username] end + def account_id_param + params[:id] + end + def skip_temporary_suspension_response? request.format == :json end diff --git a/app/controllers/concerns/account_owned_concern.rb b/app/controllers/concerns/account_owned_concern.rb index 2b132417f7..4cfee28ac7 100644 --- a/app/controllers/concerns/account_owned_concern.rb +++ b/app/controllers/concerns/account_owned_concern.rb @@ -18,7 +18,11 @@ module AccountOwnedConcern end def set_account - @account = Account.find_local!(username_param) + @account = username_param.present? ? Account.find_local!(username_param) : Account.local.find(account_id_param) + end + + def account_id_param + params[:numeric_account_id] end def username_param diff --git a/config/routes.rb b/config/routes.rb index 3909dd1b77..6dc9fb90a6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -117,6 +117,29 @@ Rails.application.routes.draw do end end + resources :accounts, path: 'u', only: [:show], param: :id, as: :numeric_account 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 + + scope module: :activitypub do + resource :outbox, only: [:show] + resource :inbox, only: [:create] + resources :collections, only: [:show] + resource :followers_synchronization, only: [:show] + end + end + resource :inbox, only: [:create], module: :activitypub constraints(encoded_path: /%40.*/) do diff --git a/spec/requests/accounts_spec.rb b/spec/requests/accounts_spec.rb index afd9ac80e2..4172a8b657 100644 --- a/spec/requests/accounts_spec.rb +++ b/spec/requests/accounts_spec.rb @@ -5,6 +5,14 @@ require 'rails_helper' RSpec.describe 'Accounts show response' do let(:account) { Fabricate(:account) } + context 'with numeric-based identifiers' do + it 'returns http success' do + get "/u/#{account.id}" + + expect(response).to have_http_status(200) + end + end + context 'with an unapproved account' do before { account.user.update(approved: false) }