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