Redirect if collection AP ID is requested as HTML (#39361)

This commit is contained in:
David Roetzel authored and GitHub committed 2026-06-10 15:54:50 +00:00
1 parent 1bbe3872f2
commit 008f377a37
2 files changed
+13

No files matched your search

@@ -10,6 +10,7 @@ class CollectionsController < ApplicationController
before_action :require_account_signature!, only: :show, if: -> { request.format == :json && authorized_fetch_mode? }
before_action :set_collection
before_action :redirect_to_canonical_url
skip_around_action :set_locale, if: -> { request.format == :json }
skip_before_action :require_functional!, only: :show, unless: :limited_federation_mode?
@@ -45,6 +46,10 @@ class CollectionsController < ApplicationController
not_found
end
def redirect_to_canonical_url
redirect_to collection_path(@collection) if request.format.html? && request.path.starts_with?('/ap/')
end
def expiration_duration
recently_updated = @collection.updated_at > 15.minutes.ago
recently_updated ? 30.seconds : 5.minutes
+8
View File
@@ -29,6 +29,14 @@ RSpec.describe 'Collections' do
let(:collection) { Fabricate(:collection) }
let(:account) { collection.account }
context 'when requested as HTML' do
it 'redirects to canonical URL' do
get ap_account_collection_path(account.id, collection)
expect(response).to redirect_to(collection_path(collection))
end
end
context 'when signed out' do
context 'when account is permanently suspended' do
before do