mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-13 15:58:50 +00:00
Merge commit 'f1a6f4333a75f5bc186334f7f43a26e969cd712d' into glitch-soc/merge-upstream
This commit is contained in:
@@ -9,18 +9,17 @@ class Mastodon::RedisConfiguration
|
||||
|
||||
def base
|
||||
@base ||= setup_config(prefix: nil, defaults: DEFAULTS)
|
||||
.merge(namespace: base_namespace)
|
||||
.merge(namespace: nil)
|
||||
end
|
||||
|
||||
def sidekiq
|
||||
@sidekiq ||= setup_config(prefix: 'SIDEKIQ_')
|
||||
.merge(namespace: sidekiq_namespace)
|
||||
end
|
||||
|
||||
def cache
|
||||
@cache ||= setup_config(prefix: 'CACHE_')
|
||||
.merge({
|
||||
namespace: cache_namespace,
|
||||
namespace: 'cache',
|
||||
expires_in: 10.minutes,
|
||||
connect_timeout: 5,
|
||||
pool: {
|
||||
@@ -36,24 +35,6 @@ class Mastodon::RedisConfiguration
|
||||
ENV['REDIS_DRIVER'] == 'ruby' ? :ruby : :hiredis
|
||||
end
|
||||
|
||||
def namespace
|
||||
@namespace ||= ENV.fetch('REDIS_NAMESPACE', nil)
|
||||
end
|
||||
|
||||
def base_namespace
|
||||
return "mastodon_test#{ENV.fetch('TEST_ENV_NUMBER', nil)}" if Rails.env.test?
|
||||
|
||||
namespace
|
||||
end
|
||||
|
||||
def sidekiq_namespace
|
||||
namespace
|
||||
end
|
||||
|
||||
def cache_namespace
|
||||
namespace ? "#{namespace}_cache" : 'cache'
|
||||
end
|
||||
|
||||
def setup_config(prefix: nil, defaults: {})
|
||||
prefix = "#{prefix}REDIS_"
|
||||
|
||||
@@ -62,7 +43,7 @@ class Mastodon::RedisConfiguration
|
||||
password = ENV.fetch("#{prefix}PASSWORD", nil)
|
||||
host = ENV.fetch("#{prefix}HOST", defaults[:host])
|
||||
port = ENV.fetch("#{prefix}PORT", defaults[:port])
|
||||
db = ENV.fetch("#{prefix}DB", defaults[:db])
|
||||
db = Rails.env.test? ? ENV.fetch('TEST_ENV_NUMBER', defaults[:db]).to_i + 1 : ENV.fetch("#{prefix}DB", defaults[:db])
|
||||
|
||||
return { url:, driver: } if url
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Redis
|
||||
module NamespaceExtensions
|
||||
def exists?(...)
|
||||
call_with_namespace('exists?', ...)
|
||||
end
|
||||
|
||||
def with
|
||||
yield self
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Redis::Namespace::COMMANDS['exists?'] = [:first]
|
||||
Redis::Namespace.prepend(Redis::NamespaceExtensions)
|
||||
@@ -63,7 +63,7 @@ namespace :db do
|
||||
|
||||
task pre_migration_check: :environment do
|
||||
pg_version = ActiveRecord::Base.connection.database_version
|
||||
abort 'This version of Mastodon requires PostgreSQL 12.0 or newer. Please update PostgreSQL before updating Mastodon.' if pg_version < 120_000
|
||||
abort 'This version of Mastodon requires PostgreSQL 13.0 or newer. Please update PostgreSQL before updating Mastodon.' if pg_version < 130_000
|
||||
|
||||
schema_version = ActiveRecord::Migrator.current_version
|
||||
abort <<~MESSAGE if ENV['SKIP_POST_DEPLOYMENT_MIGRATIONS'] && schema_version < 2023_09_07_150100
|
||||
|
||||
@@ -11,7 +11,8 @@ namespace :dev do
|
||||
password: SecureRandom.hex,
|
||||
email: ENV.fetch('TEST_DATA_SHOWCASE_EMAIL', 'showcase_account@joinmastodon.org'),
|
||||
confirmed_at: Time.now.utc,
|
||||
approved: true
|
||||
approved: true,
|
||||
bypass_registration_checks: true
|
||||
).find_or_create_by!(id: 10_000_000)
|
||||
showcase_user.mark_email_as_confirmed!
|
||||
showcase_user.approve!
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace :mastodon do
|
||||
prompt.say('Single user mode disables registrations and redirects the landing page to your public profile.')
|
||||
env['SINGLE_USER_MODE'] = prompt.yes?('Do you want to enable single user mode?', default: false)
|
||||
|
||||
%w(SECRET_KEY_BASE OTP_SECRET).each do |key|
|
||||
%w(SECRET_KEY_BASE).each do |key|
|
||||
env[key] = SecureRandom.hex(64)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user