mirror of
https://github.com/mastodon/mastodon.git
synced 2026-10-13 10:40:02 -05:00
Fix HTTP 200 response code on paths to remote accounts that don't exist (#40341)
This commit is contained in:
@@ -27,10 +27,7 @@ module WebAppControllerConcern
|
||||
end
|
||||
|
||||
def redirect_unauthenticated_to_permalinks!
|
||||
return if user_signed_in? && current_account.moved_to_account_id.nil?
|
||||
|
||||
permalink_redirector = PermalinkRedirector.new(request.original_fullpath)
|
||||
return if permalink_redirector.redirect_path.blank?
|
||||
return if (user_signed_in? && current_account.moved_to_account_id.nil?) || permalink_redirector.redirect_path.blank?
|
||||
|
||||
expires_in(15.seconds, public: true, stale_while_revalidate: 30.seconds, stale_if_error: 1.day) unless user_signed_in?
|
||||
|
||||
@@ -72,4 +69,8 @@ module WebAppControllerConcern
|
||||
def set_referer_header
|
||||
response.set_header('Referrer-Policy', Setting.allow_referrer_origin ? 'strict-origin-when-cross-origin' : 'same-origin')
|
||||
end
|
||||
|
||||
def permalink_redirector
|
||||
@permalink_redirector ||= PermalinkRedirector.new(request.original_fullpath)
|
||||
end
|
||||
end
|
||||
|
||||
12
app/controllers/remote_accounts_controller.rb
Normal file
12
app/controllers/remote_accounts_controller.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class RemoteAccountsController < HomeController
|
||||
before_action :require_resource_exists!
|
||||
|
||||
private
|
||||
|
||||
def require_resource_exists!
|
||||
# The page should still render normally, but the HTTP code should be modified
|
||||
response.status = 404 if permalink_redirector.object.nil?
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user