mirror of
https://github.com/mastodon/mastodon
synced 2024-12-12 21:58:20 +09:00
Add support for numeric-based URIs for local accounts
This commit is contained in:
parent
0a1b5df202
commit
c4179b333f
@ -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
|
||||
|
@ -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
|
||||
|
@ -148,6 +148,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
|
||||
|
@ -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) }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user