mirror of
https://github.com/mastodon/mastodon.git
synced 2025-07-15 08:48:15 +00:00
Move "limited federation mode" config to x.mastodon
area (#35041)
This commit is contained in:
parent
ed4788a342
commit
6f2aba989f
|
@ -1,6 +1,6 @@
|
|||
# This configuration was generated by
|
||||
# `rubocop --auto-gen-config --auto-gen-only-exclude --no-offense-counts --no-auto-gen-timestamp`
|
||||
# using RuboCop version 1.76.0.
|
||||
# using RuboCop version 1.76.1.
|
||||
# The point is for the user to remove these configuration records
|
||||
# one by one as the offenses are removed from the code base.
|
||||
# Note that changes in the inspected code, or installation of new
|
||||
|
@ -31,7 +31,6 @@ Metrics/PerceivedComplexity:
|
|||
# Configuration parameters: AllowedVars.
|
||||
Style/FetchEnvVar:
|
||||
Exclude:
|
||||
- 'config/initializers/2_limited_federation_mode.rb'
|
||||
- 'config/initializers/paperclip.rb'
|
||||
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
|
|
|
@ -92,7 +92,7 @@ class Api::BaseController < ApplicationController
|
|||
end
|
||||
|
||||
def disallow_unauthenticated_api_access?
|
||||
ENV['DISALLOW_UNAUTHENTICATED_API_ACCESS'] == 'true' || Rails.configuration.x.limited_federation_mode
|
||||
ENV['DISALLOW_UNAUTHENTICATED_API_ACCESS'] == 'true' || Rails.configuration.x.mastodon.limited_federation_mode
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
module AuthorizedFetchHelper
|
||||
def authorized_fetch_mode?
|
||||
ENV.fetch('AUTHORIZED_FETCH') { Setting.authorized_fetch && 'true' } == 'true' || Rails.configuration.x.limited_federation_mode
|
||||
ENV.fetch('AUTHORIZED_FETCH') { Setting.authorized_fetch && 'true' } == 'true' || Rails.configuration.x.mastodon.limited_federation_mode
|
||||
end
|
||||
|
||||
def authorized_fetch_overridden?
|
||||
ENV.key?('AUTHORIZED_FETCH') || Rails.configuration.x.limited_federation_mode
|
||||
ENV.key?('AUTHORIZED_FETCH') || Rails.configuration.x.mastodon.limited_federation_mode
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,6 +18,6 @@ module DomainControlHelper
|
|||
end
|
||||
|
||||
def limited_federation_mode?
|
||||
Rails.configuration.x.limited_federation_mode
|
||||
Rails.configuration.x.mastodon.limited_federation_mode
|
||||
end
|
||||
end
|
||||
|
|
|
@ -93,7 +93,7 @@ class InitialStateSerializer < ActiveModel::Serializer
|
|||
activity_api_enabled: Setting.activity_api_enabled,
|
||||
admin: object.admin&.id&.to_s,
|
||||
domain: Addressable::IDNA.to_unicode(instance_presenter.domain),
|
||||
limited_federation_mode: Rails.configuration.x.limited_federation_mode,
|
||||
limited_federation_mode: Rails.configuration.x.mastodon.limited_federation_mode,
|
||||
locale: I18n.locale,
|
||||
mascot: instance_presenter.mascot&.file&.url,
|
||||
profile_directory: Setting.profile_directory,
|
||||
|
|
|
@ -130,7 +130,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer
|
|||
end
|
||||
|
||||
def limited_federation?
|
||||
Rails.configuration.x.limited_federation_mode
|
||||
Rails.configuration.x.mastodon.limited_federation_mode
|
||||
end
|
||||
|
||||
def markdown
|
||||
|
|
|
@ -33,7 +33,7 @@ class WebfingerSerializer < ActiveModel::Serializer
|
|||
media_present = object.avatar.present? && object.avatar.content_type.present?
|
||||
|
||||
# Show avatar only if an instance shows profiles to logged out users
|
||||
allowed_by_config = ENV['DISALLOW_UNAUTHENTICATED_API_ACCESS'] != 'true' && !Rails.configuration.x.limited_federation_mode
|
||||
allowed_by_config = ENV['DISALLOW_UNAUTHENTICATED_API_ACCESS'] != 'true' && !Rails.configuration.x.mastodon.limited_federation_mode
|
||||
|
||||
media_present && allowed_by_config
|
||||
end
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Rails.application.configure do
|
||||
config.x.limited_federation_mode = (ENV['LIMITED_FEDERATION_MODE'] || ENV['WHITELIST_MODE']) == 'true'
|
||||
|
||||
warn 'WARN: The environment variable WHITELIST_MODE has been replaced with LIMITED_FEDERATION_MODE, you should rename this environment variable in your configuration.' if ENV.key?('WHITELIST_MODE')
|
||||
end
|
|
@ -22,3 +22,10 @@ if ENV['MASTODON_USE_LIBVIPS'] == 'false'
|
|||
WARNING: Mastodon support for ImageMagick is deprecated and will be removed in future versions. Please consider using libvips instead.
|
||||
MESSAGE
|
||||
end
|
||||
|
||||
if ENV.key?('WHITELIST_MODE')
|
||||
warn(<<~MESSAGE.squish)
|
||||
WARNING: The environment variable WHITELIST_MODE has been replaced with
|
||||
LIMITED_FEDERATION_MODE. Please update your configuration.
|
||||
MESSAGE
|
||||
end
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
shared:
|
||||
experimental_features: <%= ENV.fetch('EXPERIMENTAL_FEATURES', nil) %>
|
||||
limited_federation_mode: <%= (ENV.fetch('LIMITED_FEDERATION_MODE', nil) || ENV.fetch('WHITELIST_MODE', nil)) == 'true' %>
|
||||
self_destruct_value: <%= ENV.fetch('SELF_DESTRUCT', nil) %>
|
||||
software_update_url: <%= ENV.fetch('UPDATE_CHECK_URL', 'https://api.joinmastodon.org/update-check') %>
|
||||
source:
|
||||
|
|
|
@ -472,12 +472,12 @@ RSpec.describe 'Caching behavior' do
|
|||
context 'when enabling LIMITED_FEDERATION_MODE mode' do
|
||||
around do |example|
|
||||
ClimateControl.modify LIMITED_FEDERATION_MODE: 'true' do
|
||||
old_limited_federation_mode = Rails.configuration.x.limited_federation_mode
|
||||
Rails.configuration.x.limited_federation_mode = true
|
||||
old_limited_federation_mode = Rails.configuration.x.mastodon.limited_federation_mode
|
||||
Rails.configuration.x.mastodon.limited_federation_mode = true
|
||||
|
||||
example.run
|
||||
|
||||
Rails.configuration.x.limited_federation_mode = old_limited_federation_mode
|
||||
Rails.configuration.x.mastodon.limited_federation_mode = old_limited_federation_mode
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ require 'rails_helper'
|
|||
|
||||
RSpec.describe 'Instance actor endpoint' do
|
||||
describe 'GET /actor' do
|
||||
let!(:original_federation_mode) { Rails.configuration.x.limited_federation_mode }
|
||||
let!(:original_federation_mode) { Rails.configuration.x.mastodon.limited_federation_mode }
|
||||
|
||||
shared_examples 'instance actor endpoint' do
|
||||
before { get instance_actor_path(format: :json) }
|
||||
|
@ -31,8 +31,8 @@ RSpec.describe 'Instance actor endpoint' do
|
|||
end
|
||||
|
||||
context 'with limited federation mode disabled' do
|
||||
before { Rails.configuration.x.limited_federation_mode = false }
|
||||
after { Rails.configuration.x.limited_federation_mode = original_federation_mode }
|
||||
before { Rails.configuration.x.mastodon.limited_federation_mode = false }
|
||||
after { Rails.configuration.x.mastodon.limited_federation_mode = original_federation_mode }
|
||||
|
||||
it_behaves_like 'instance actor endpoint'
|
||||
|
||||
|
@ -44,8 +44,8 @@ RSpec.describe 'Instance actor endpoint' do
|
|||
end
|
||||
|
||||
context 'with limited federation mode enabled' do
|
||||
before { Rails.configuration.x.limited_federation_mode = true }
|
||||
after { Rails.configuration.x.limited_federation_mode = original_federation_mode }
|
||||
before { Rails.configuration.x.mastodon.limited_federation_mode = true }
|
||||
after { Rails.configuration.x.mastodon.limited_federation_mode = original_federation_mode }
|
||||
|
||||
it_behaves_like 'instance actor endpoint'
|
||||
|
||||
|
|
|
@ -176,7 +176,7 @@ RSpec.describe 'The /.well-known/webfinger endpoint' do
|
|||
|
||||
context 'with limited federation mode' do
|
||||
before do
|
||||
allow(Rails.configuration.x).to receive(:limited_federation_mode).and_return(true)
|
||||
allow(Rails.configuration.x.mastodon).to receive(:limited_federation_mode).and_return(true)
|
||||
end
|
||||
|
||||
it 'does not return avatar in response' do
|
||||
|
|
|
@ -15,7 +15,7 @@ RSpec.describe UnallowDomainService do
|
|||
|
||||
context 'with limited federation mode', :inline_jobs do
|
||||
before do
|
||||
allow(Rails.configuration.x).to receive(:limited_federation_mode).and_return(true)
|
||||
allow(Rails.configuration.x.mastodon).to receive(:limited_federation_mode).and_return(true)
|
||||
end
|
||||
|
||||
describe '#call' do
|
||||
|
@ -34,7 +34,7 @@ RSpec.describe UnallowDomainService do
|
|||
|
||||
context 'without limited federation mode' do
|
||||
before do
|
||||
allow(Rails.configuration.x).to receive(:limited_federation_mode).and_return(false)
|
||||
allow(Rails.configuration.x.mastodon).to receive(:limited_federation_mode).and_return(false)
|
||||
end
|
||||
|
||||
describe '#call' do
|
||||
|
|
|
@ -13,12 +13,12 @@ RSpec.describe 'Admin::DomainAllows' do
|
|||
end
|
||||
|
||||
around do |example|
|
||||
original = Rails.configuration.x.limited_federation_mode
|
||||
Rails.configuration.x.limited_federation_mode = true
|
||||
original = Rails.configuration.x.mastodon.limited_federation_mode
|
||||
Rails.configuration.x.mastodon.limited_federation_mode = true
|
||||
|
||||
example.run
|
||||
|
||||
Rails.configuration.x.limited_federation_mode = original
|
||||
Rails.configuration.x.mastodon.limited_federation_mode = original
|
||||
end
|
||||
|
||||
describe 'Managing domain allows' do
|
||||
|
|
Loading…
Reference in New Issue
Block a user