Browse Source

add noindex header to statuses#show

tags/v3.0.0-adneyland
James Adney 3 weeks ago
parent
commit
a9812dba9b

+ 4
- 1
app/controllers/statuses_controller.rb View File

@@ -76,7 +76,10 @@ class StatusesController < ApplicationController
end

def redirect_to_original
redirect_to ActivityPub::TagManager.instance.url_for(@status.reblog) if @status.reblog?
return unless @status.reblog?

response.headers['X-Robots-Tag'] = 'noindex' if @account.user&.setting_noindex
redirect_to ActivityPub::TagManager.instance.url_for(@status.reblog)
end

def set_referrer_policy_header

+ 16
- 0
spec/controllers/statuses_controller_spec.rb View File

@@ -40,6 +40,22 @@ describe StatusesController do

expect(response).to redirect_to(original_status.url)
end

it 'reflects noindex setting' do
original_account = Fabricate(:account, domain: 'example.com')
original_status = Fabricate(:status, account: original_account, uri: 'tag:example.com,2017:foo', url: 'https://example.com/123')

account = Fabricate(:account, user: Fabricate(:user))
status = Fabricate(:status, account: account, reblog: original_status)

account.user.settings['noindex'] = false
get :show, params: { account_username: status.account.username, id: status.id }
expect(response.headers['X-Robots-Tag']).to_not eq('noindex')

account.user.settings['noindex'] = true
get :show, params: { account_username: status.account.username, id: status.id }
expect(response.headers['X-Robots-Tag']).to eq('noindex')
end
end

context 'account is not suspended and status is permitted' do

Loading…
Cancel
Save