Remove duplicate cache header setting before action (#33833)
This commit is contained in:
		
							parent
							
								
									8dce5138dd
								
							
						
					
					
						commit
						c3419d146a
					
				@ -7,17 +7,12 @@ module Admin
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    layout 'admin'
 | 
					    layout 'admin'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    before_action :set_cache_headers
 | 
					 | 
				
			||||||
    before_action :set_referrer_policy_header
 | 
					    before_action :set_referrer_policy_header
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    after_action :verify_authorized
 | 
					    after_action :verify_authorized
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private
 | 
					    private
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def set_cache_headers
 | 
					 | 
				
			||||||
      response.cache_control.replace(private: true, no_store: true)
 | 
					 | 
				
			||||||
    end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    def set_referrer_policy_header
 | 
					    def set_referrer_policy_header
 | 
				
			||||||
      response.headers['Referrer-Policy'] = 'same-origin'
 | 
					      response.headers['Referrer-Policy'] = 'same-origin'
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
				
			|||||||
@ -12,7 +12,6 @@ class Auth::RegistrationsController < Devise::RegistrationsController
 | 
				
			|||||||
  before_action :set_sessions, only: [:edit, :update]
 | 
					  before_action :set_sessions, only: [:edit, :update]
 | 
				
			||||||
  before_action :set_strikes, only: [:edit, :update]
 | 
					  before_action :set_strikes, only: [:edit, :update]
 | 
				
			||||||
  before_action :require_not_suspended!, only: [:update]
 | 
					  before_action :require_not_suspended!, only: [:update]
 | 
				
			||||||
  before_action :set_cache_headers, only: [:edit, :update]
 | 
					 | 
				
			||||||
  before_action :set_rules, only: :new
 | 
					  before_action :set_rules, only: :new
 | 
				
			||||||
  before_action :require_rules_acceptance!, only: :new
 | 
					  before_action :require_rules_acceptance!, only: :new
 | 
				
			||||||
  before_action :set_registration_form_time, only: :new
 | 
					  before_action :set_registration_form_time, only: :new
 | 
				
			||||||
@ -139,10 +138,6 @@ class Auth::RegistrationsController < Devise::RegistrationsController
 | 
				
			|||||||
    set_locale { render :rules }
 | 
					    set_locale { render :rules }
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def set_cache_headers
 | 
					 | 
				
			||||||
    response.cache_control.replace(private: true, no_store: true)
 | 
					 | 
				
			||||||
  end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  def is_flashing_format? # rubocop:disable Naming/PredicateName
 | 
					  def is_flashing_format? # rubocop:disable Naming/PredicateName
 | 
				
			||||||
    if params[:action] == 'create'
 | 
					    if params[:action] == 'create'
 | 
				
			||||||
      false # Disable flash messages for sign-up
 | 
					      false # Disable flash messages for sign-up
 | 
				
			||||||
 | 
				
			|||||||
@ -8,11 +8,4 @@ class Disputes::BaseController < ApplicationController
 | 
				
			|||||||
  skip_before_action :require_functional!
 | 
					  skip_before_action :require_functional!
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  before_action :authenticate_user!
 | 
					  before_action :authenticate_user!
 | 
				
			||||||
  before_action :set_cache_headers
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  private
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  def set_cache_headers
 | 
					 | 
				
			||||||
    response.cache_control.replace(private: true, no_store: true)
 | 
					 | 
				
			||||||
  end
 | 
					 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
				
			|||||||
@ -6,7 +6,6 @@ class Filters::StatusesController < ApplicationController
 | 
				
			|||||||
  before_action :authenticate_user!
 | 
					  before_action :authenticate_user!
 | 
				
			||||||
  before_action :set_filter
 | 
					  before_action :set_filter
 | 
				
			||||||
  before_action :set_status_filters
 | 
					  before_action :set_status_filters
 | 
				
			||||||
  before_action :set_cache_headers
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  PER_PAGE = 20
 | 
					  PER_PAGE = 20
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -40,8 +39,4 @@ class Filters::StatusesController < ApplicationController
 | 
				
			|||||||
  def action_from_button
 | 
					  def action_from_button
 | 
				
			||||||
    'remove' if params[:remove]
 | 
					    'remove' if params[:remove]
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					 | 
				
			||||||
  def set_cache_headers
 | 
					 | 
				
			||||||
    response.cache_control.replace(private: true, no_store: true)
 | 
					 | 
				
			||||||
  end
 | 
					 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
				
			|||||||
@ -5,7 +5,6 @@ class FiltersController < ApplicationController
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  before_action :authenticate_user!
 | 
					  before_action :authenticate_user!
 | 
				
			||||||
  before_action :set_filter, only: [:edit, :update, :destroy]
 | 
					  before_action :set_filter, only: [:edit, :update, :destroy]
 | 
				
			||||||
  before_action :set_cache_headers
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def index
 | 
					  def index
 | 
				
			||||||
    @filters = current_account.custom_filters.includes(:keywords, :statuses).order(:phrase)
 | 
					    @filters = current_account.custom_filters.includes(:keywords, :statuses).order(:phrase)
 | 
				
			||||||
@ -50,8 +49,4 @@ class FiltersController < ApplicationController
 | 
				
			|||||||
  def resource_params
 | 
					  def resource_params
 | 
				
			||||||
    params.expect(custom_filter: [:title, :expires_in, :filter_action, context: [], keywords_attributes: [[:id, :keyword, :whole_word, :_destroy]]])
 | 
					    params.expect(custom_filter: [:title, :expires_in, :filter_action, context: [], keywords_attributes: [[:id, :keyword, :whole_word, :_destroy]]])
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					 | 
				
			||||||
  def set_cache_headers
 | 
					 | 
				
			||||||
    response.cache_control.replace(private: true, no_store: true)
 | 
					 | 
				
			||||||
  end
 | 
					 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
				
			|||||||
@ -6,7 +6,6 @@ class InvitesController < ApplicationController
 | 
				
			|||||||
  layout 'admin'
 | 
					  layout 'admin'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  before_action :authenticate_user!
 | 
					  before_action :authenticate_user!
 | 
				
			||||||
  before_action :set_cache_headers
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def index
 | 
					  def index
 | 
				
			||||||
    authorize :invite, :create?
 | 
					    authorize :invite, :create?
 | 
				
			||||||
@ -45,8 +44,4 @@ class InvitesController < ApplicationController
 | 
				
			|||||||
  def resource_params
 | 
					  def resource_params
 | 
				
			||||||
    params.expect(invite: [:max_uses, :expires_in, :autofollow, :comment])
 | 
					    params.expect(invite: [:max_uses, :expires_in, :autofollow, :comment])
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					 | 
				
			||||||
  def set_cache_headers
 | 
					 | 
				
			||||||
    response.cache_control.replace(private: true, no_store: true)
 | 
					 | 
				
			||||||
  end
 | 
					 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
				
			|||||||
@ -5,7 +5,6 @@ class Oauth::AuthorizationsController < Doorkeeper::AuthorizationsController
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  before_action :store_current_location
 | 
					  before_action :store_current_location
 | 
				
			||||||
  before_action :authenticate_resource_owner!
 | 
					  before_action :authenticate_resource_owner!
 | 
				
			||||||
  before_action :set_cache_headers
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  content_security_policy do |p|
 | 
					  content_security_policy do |p|
 | 
				
			||||||
    p.form_action(false)
 | 
					    p.form_action(false)
 | 
				
			||||||
@ -32,8 +31,4 @@ class Oauth::AuthorizationsController < Doorkeeper::AuthorizationsController
 | 
				
			|||||||
  def truthy_param?(key)
 | 
					  def truthy_param?(key)
 | 
				
			||||||
    ActiveModel::Type::Boolean.new.cast(params[key])
 | 
					    ActiveModel::Type::Boolean.new.cast(params[key])
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					 | 
				
			||||||
  def set_cache_headers
 | 
					 | 
				
			||||||
    response.cache_control.replace(private: true, no_store: true)
 | 
					 | 
				
			||||||
  end
 | 
					 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
				
			|||||||
@ -6,7 +6,6 @@ class Oauth::AuthorizedApplicationsController < Doorkeeper::AuthorizedApplicatio
 | 
				
			|||||||
  before_action :store_current_location
 | 
					  before_action :store_current_location
 | 
				
			||||||
  before_action :authenticate_resource_owner!
 | 
					  before_action :authenticate_resource_owner!
 | 
				
			||||||
  before_action :require_not_suspended!, only: :destroy
 | 
					  before_action :require_not_suspended!, only: :destroy
 | 
				
			||||||
  before_action :set_cache_headers
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  before_action :set_last_used_at_by_app, only: :index, unless: -> { request.format == :json }
 | 
					  before_action :set_last_used_at_by_app, only: :index, unless: -> { request.format == :json }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -30,10 +29,6 @@ class Oauth::AuthorizedApplicationsController < Doorkeeper::AuthorizedApplicatio
 | 
				
			|||||||
    forbidden if current_account.unavailable?
 | 
					    forbidden if current_account.unavailable?
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def set_cache_headers
 | 
					 | 
				
			||||||
    response.cache_control.replace(private: true, no_store: true)
 | 
					 | 
				
			||||||
  end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  def set_last_used_at_by_app
 | 
					  def set_last_used_at_by_app
 | 
				
			||||||
    @last_used_at_by_app = current_resource_owner.applications_last_used
 | 
					    @last_used_at_by_app = current_resource_owner.applications_last_used
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
				
			|||||||
@ -6,7 +6,6 @@ class RelationshipsController < ApplicationController
 | 
				
			|||||||
  before_action :authenticate_user!
 | 
					  before_action :authenticate_user!
 | 
				
			||||||
  before_action :set_accounts, only: :show
 | 
					  before_action :set_accounts, only: :show
 | 
				
			||||||
  before_action :set_relationships, only: :show
 | 
					  before_action :set_relationships, only: :show
 | 
				
			||||||
  before_action :set_cache_headers
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  helper_method :following_relationship?, :followed_by_relationship?, :mutual_relationship?
 | 
					  helper_method :following_relationship?, :followed_by_relationship?, :mutual_relationship?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -66,8 +65,4 @@ class RelationshipsController < ApplicationController
 | 
				
			|||||||
      'remove_domains_from_followers'
 | 
					      'remove_domains_from_followers'
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					 | 
				
			||||||
  def set_cache_headers
 | 
					 | 
				
			||||||
    response.cache_control.replace(private: true, no_store: true)
 | 
					 | 
				
			||||||
  end
 | 
					 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
				
			|||||||
@ -4,14 +4,9 @@ class Settings::BaseController < ApplicationController
 | 
				
			|||||||
  layout 'admin'
 | 
					  layout 'admin'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  before_action :authenticate_user!
 | 
					  before_action :authenticate_user!
 | 
				
			||||||
  before_action :set_cache_headers
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private
 | 
					  private
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def set_cache_headers
 | 
					 | 
				
			||||||
    response.cache_control.replace(private: true, no_store: true)
 | 
					 | 
				
			||||||
  end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  def require_not_suspended!
 | 
					  def require_not_suspended!
 | 
				
			||||||
    forbidden if current_account.unavailable?
 | 
					    forbidden if current_account.unavailable?
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
				
			|||||||
@ -4,7 +4,6 @@ class SeveredRelationshipsController < ApplicationController
 | 
				
			|||||||
  layout 'admin'
 | 
					  layout 'admin'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  before_action :authenticate_user!
 | 
					  before_action :authenticate_user!
 | 
				
			||||||
  before_action :set_cache_headers
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  before_action :set_event, only: [:following, :followers]
 | 
					  before_action :set_event, only: [:following, :followers]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -49,8 +48,4 @@ class SeveredRelationshipsController < ApplicationController
 | 
				
			|||||||
  def acct(account)
 | 
					  def acct(account)
 | 
				
			||||||
    account.local? ? account.local_username_and_domain : account.acct
 | 
					    account.local? ? account.local_username_and_domain : account.acct
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					 | 
				
			||||||
  def set_cache_headers
 | 
					 | 
				
			||||||
    response.cache_control.replace(private: true, no_store: true)
 | 
					 | 
				
			||||||
  end
 | 
					 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
				
			|||||||
@ -5,7 +5,6 @@ class StatusesCleanupController < ApplicationController
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  before_action :authenticate_user!
 | 
					  before_action :authenticate_user!
 | 
				
			||||||
  before_action :set_policy
 | 
					  before_action :set_policy
 | 
				
			||||||
  before_action :set_cache_headers
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def show; end
 | 
					  def show; end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -30,8 +29,4 @@ class StatusesCleanupController < ApplicationController
 | 
				
			|||||||
  def resource_params
 | 
					  def resource_params
 | 
				
			||||||
    params.expect(account_statuses_cleanup_policy: [:enabled, :min_status_age, :keep_direct, :keep_pinned, :keep_polls, :keep_media, :keep_self_fav, :keep_self_bookmark, :min_favs, :min_reblogs])
 | 
					    params.expect(account_statuses_cleanup_policy: [:enabled, :min_status_age, :keep_direct, :keep_pinned, :keep_polls, :keep_media, :keep_self_fav, :keep_self_bookmark, :min_favs, :min_reblogs])
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					 | 
				
			||||||
  def set_cache_headers
 | 
					 | 
				
			||||||
    response.cache_control.replace(private: true, no_store: true)
 | 
					 | 
				
			||||||
  end
 | 
					 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user