Redirect to short account URLs when requesting HTML for one of the AP endpoints (#38056)
This commit is contained in:
@@ -18,6 +18,8 @@ class AccountsController < ApplicationController
|
|||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html do
|
format.html do
|
||||||
expires_in(15.seconds, public: true, stale_while_revalidate: 30.seconds, stale_if_error: 1.hour) unless user_signed_in?
|
expires_in(15.seconds, public: true, stale_while_revalidate: 30.seconds, stale_if_error: 1.hour) unless user_signed_in?
|
||||||
|
|
||||||
|
redirect_to short_account_path(@account) if account_id_param.present? && username_param.blank?
|
||||||
end
|
end
|
||||||
|
|
||||||
format.rss do
|
format.rss do
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ class StatusesController < ApplicationController
|
|||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html do
|
format.html do
|
||||||
expires_in 10.seconds, public: true if current_account.nil?
|
expires_in 10.seconds, public: true if current_account.nil?
|
||||||
|
|
||||||
|
redirect_to short_account_status_path(@account, @status) if account_id_param.present? && username_param.blank?
|
||||||
end
|
end
|
||||||
|
|
||||||
format.json do
|
format.json do
|
||||||
|
|||||||
@@ -6,10 +6,20 @@ RSpec.describe 'Accounts show response' do
|
|||||||
let(:account) { Fabricate(:account) }
|
let(:account) { Fabricate(:account) }
|
||||||
|
|
||||||
context 'with numeric-based identifiers' do
|
context 'with numeric-based identifiers' do
|
||||||
it 'returns http success' do
|
context 'with JSON format' do
|
||||||
get "/ap/users/#{account.id}"
|
it 'returns http success' do
|
||||||
|
get "/ap/users/#{account.id}", headers: { 'ACCEPT' => 'application/json' }
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(200)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with HTML format' do
|
||||||
|
it 'redirects to success' do
|
||||||
|
get "/ap/users/#{account.id}", as: 'html'
|
||||||
|
|
||||||
|
expect(response).to redirect_to("/@#{account.username}")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user