Redirect with interstitial when trying to view a remote collection while logged out (#38941)

This commit is contained in:
Claire authored and GitHub committed 2026-05-07 16:04:26 +00:00
1 parent 496d41cdce
commit b2aa476abb
4 files changed
+32

No files matched your search

@@ -0,0 +1,10 @@
# frozen_string_literal: true
class Redirect::CollectionsController < Redirect::BaseController
private
def set_resource
@resource = Collection.find(params[:id])
not_found if @resource.local? || @resource&.account&.suspended?
end
end
+9
View File
@@ -21,6 +21,9 @@ class PermalinkRedirector
elsif accounts_request? && record_integer_id_request?
account = Account.find_by(id: second_segment)
account if !account&.local? && !account&.suspended?
elsif collections_request? && record_integer_id_request?
collection = Collection.find_by(id: second_segment)
collection if !collection&.local? && !collection&.account&.suspended?
end
end
end
@@ -43,6 +46,8 @@ class PermalinkRedirector
redirect_account_path(object.id)
when 'Status'
redirect_status_path(object.id)
when 'Collection'
redirect_collection_path(object.id)
else
@path.delete_prefix('/deck') if @path.start_with?('/deck')
end
@@ -70,6 +75,10 @@ class PermalinkRedirector
first_segment == 'accounts'
end
def collections_request?
first_segment == 'collections'
end
def record_integer_id_request?
second_segment =~ /\d/
end