Revert "Rails 7 update" (#25667)

th-downstream
Eugen Rochko 1 year ago committed by GitHub
parent ee22b32aef
commit edb6aab974

@ -4,7 +4,7 @@ source 'https://rubygems.org'
ruby '>= 3.0.0' ruby '>= 3.0.0'
gem 'puma', '~> 6.3' gem 'puma', '~> 6.3'
gem 'rails', '~> 7.0' gem 'rails', '~> 6.1.7'
gem 'sprockets', '~> 3.7.2' gem 'sprockets', '~> 3.7.2'
gem 'thor', '~> 1.2' gem 'thor', '~> 1.2'
gem 'rack', '~> 2.2.7' gem 'rack', '~> 2.2.7'
@ -67,7 +67,7 @@ gem 'pundit', '~> 2.3'
gem 'premailer-rails' gem 'premailer-rails'
gem 'rack-attack', '~> 6.6' gem 'rack-attack', '~> 6.6'
gem 'rack-cors', '~> 2.0', require: 'rack/cors' gem 'rack-cors', '~> 2.0', require: 'rack/cors'
gem 'rails-i18n', '~> 7.0' gem 'rails-i18n', '~> 6.0'
gem 'rails-settings-cached', '~> 0.6', git: 'https://github.com/mastodon/rails-settings-cached.git', branch: 'v0.6.6-aliases-true' gem 'rails-settings-cached', '~> 0.6', git: 'https://github.com/mastodon/rails-settings-cached.git', branch: 'v0.6.6-aliases-true'
gem 'redcarpet', '~> 3.6' gem 'redcarpet', '~> 3.6'
gem 'redis', '~> 4.5', require: ['redis', 'redis/connection/hiredis'] gem 'redis', '~> 4.5', require: ['redis', 'redis/connection/hiredis']

@ -18,47 +18,40 @@ GIT
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
actioncable (7.0.6) actioncable (6.1.7.4)
actionpack (= 7.0.6) actionpack (= 6.1.7.4)
activesupport (= 7.0.6) activesupport (= 6.1.7.4)
nio4r (~> 2.0) nio4r (~> 2.0)
websocket-driver (>= 0.6.1) websocket-driver (>= 0.6.1)
actionmailbox (7.0.6) actionmailbox (6.1.7.4)
actionpack (= 7.0.6) actionpack (= 6.1.7.4)
activejob (= 7.0.6) activejob (= 6.1.7.4)
activerecord (= 7.0.6) activerecord (= 6.1.7.4)
activestorage (= 7.0.6) activestorage (= 6.1.7.4)
activesupport (= 7.0.6) activesupport (= 6.1.7.4)
mail (>= 2.7.1) mail (>= 2.7.1)
net-imap actionmailer (6.1.7.4)
net-pop actionpack (= 6.1.7.4)
net-smtp actionview (= 6.1.7.4)
actionmailer (7.0.6) activejob (= 6.1.7.4)
actionpack (= 7.0.6) activesupport (= 6.1.7.4)
actionview (= 7.0.6)
activejob (= 7.0.6)
activesupport (= 7.0.6)
mail (~> 2.5, >= 2.5.4) mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
actionpack (7.0.6) actionpack (6.1.7.4)
actionview (= 7.0.6) actionview (= 6.1.7.4)
activesupport (= 7.0.6) activesupport (= 6.1.7.4)
rack (~> 2.0, >= 2.2.4) rack (~> 2.0, >= 2.0.9)
rack-test (>= 0.6.3) rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (7.0.6) actiontext (6.1.7.4)
actionpack (= 7.0.6) actionpack (= 6.1.7.4)
activerecord (= 7.0.6) activerecord (= 6.1.7.4)
activestorage (= 7.0.6) activestorage (= 6.1.7.4)
activesupport (= 7.0.6) activesupport (= 6.1.7.4)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5) nokogiri (>= 1.8.5)
actionview (7.0.6) actionview (6.1.7.4)
activesupport (= 7.0.6) activesupport (= 6.1.7.4)
builder (~> 3.1) builder (~> 3.1)
erubi (~> 1.4) erubi (~> 1.4)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
@ -68,26 +61,27 @@ GEM
activemodel (>= 4.1, < 7.1) activemodel (>= 4.1, < 7.1)
case_transform (>= 0.2) case_transform (>= 0.2)
jsonapi-renderer (>= 0.1.1.beta1, < 0.3) jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
activejob (7.0.6) activejob (6.1.7.4)
activesupport (= 7.0.6) activesupport (= 6.1.7.4)
globalid (>= 0.3.6) globalid (>= 0.3.6)
activemodel (7.0.6) activemodel (6.1.7.4)
activesupport (= 7.0.6) activesupport (= 6.1.7.4)
activerecord (7.0.6) activerecord (6.1.7.4)
activemodel (= 7.0.6) activemodel (= 6.1.7.4)
activesupport (= 7.0.6) activesupport (= 6.1.7.4)
activestorage (7.0.6) activestorage (6.1.7.4)
actionpack (= 7.0.6) actionpack (= 6.1.7.4)
activejob (= 7.0.6) activejob (= 6.1.7.4)
activerecord (= 7.0.6) activerecord (= 6.1.7.4)
activesupport (= 7.0.6) activesupport (= 6.1.7.4)
marcel (~> 1.0) marcel (~> 1.0)
mini_mime (>= 1.1.0) mini_mime (>= 1.1.0)
activesupport (7.0.6) activesupport (6.1.7.4)
concurrent-ruby (~> 1.0, >= 1.0.2) concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2) i18n (>= 1.6, < 2)
minitest (>= 5.1) minitest (>= 5.1)
tzinfo (~> 2.0) tzinfo (~> 2.0)
zeitwerk (~> 2.3)
addressable (2.8.4) addressable (2.8.4)
public_suffix (>= 2.0.2, < 6.0) public_suffix (>= 2.0.2, < 6.0)
aes_key_wrap (1.1.0) aes_key_wrap (1.1.0)
@ -516,20 +510,21 @@ GEM
rack rack
rack-test (2.1.0) rack-test (2.1.0)
rack (>= 1.3) rack (>= 1.3)
rails (7.0.6) rails (6.1.7.4)
actioncable (= 7.0.6) actioncable (= 6.1.7.4)
actionmailbox (= 7.0.6) actionmailbox (= 6.1.7.4)
actionmailer (= 7.0.6) actionmailer (= 6.1.7.4)
actionpack (= 7.0.6) actionpack (= 6.1.7.4)
actiontext (= 7.0.6) actiontext (= 6.1.7.4)
actionview (= 7.0.6) actionview (= 6.1.7.4)
activejob (= 7.0.6) activejob (= 6.1.7.4)
activemodel (= 7.0.6) activemodel (= 6.1.7.4)
activerecord (= 7.0.6) activerecord (= 6.1.7.4)
activestorage (= 7.0.6) activestorage (= 6.1.7.4)
activesupport (= 7.0.6) activesupport (= 6.1.7.4)
bundler (>= 1.15.0) bundler (>= 1.15.0)
railties (= 7.0.6) railties (= 6.1.7.4)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.5) rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1) actionpack (>= 5.0.1.rc1)
actionview (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1)
@ -540,16 +535,15 @@ GEM
rails-html-sanitizer (1.6.0) rails-html-sanitizer (1.6.0)
loofah (~> 2.21) loofah (~> 2.21)
nokogiri (~> 1.14) nokogiri (~> 1.14)
rails-i18n (7.0.7) rails-i18n (6.0.0)
i18n (>= 0.7, < 2) i18n (>= 0.7, < 2)
railties (>= 6.0.0, < 8) railties (>= 6.0.0, < 7)
railties (7.0.6) railties (6.1.7.4)
actionpack (= 7.0.6) actionpack (= 6.1.7.4)
activesupport (= 7.0.6) activesupport (= 6.1.7.4)
method_source method_source
rake (>= 12.2) rake (>= 12.2)
thor (~> 1.0) thor (~> 1.0)
zeitwerk (~> 2.5)
rainbow (3.1.1) rainbow (3.1.1)
rake (13.0.6) rake (13.0.6)
rdf (3.2.11) rdf (3.2.11)
@ -696,7 +690,7 @@ GEM
climate_control (>= 0.0.3, < 1.0) climate_control (>= 0.0.3, < 1.0)
thor (1.2.2) thor (1.2.2)
tilt (2.2.0) tilt (2.2.0)
timeout (0.4.0) timeout (0.3.2)
tpm-key_attestation (0.12.0) tpm-key_attestation (0.12.0)
bindata (~> 2.4) bindata (~> 2.4)
openssl (> 2.0) openssl (> 2.0)
@ -848,9 +842,9 @@ DEPENDENCIES
rack-attack (~> 6.6) rack-attack (~> 6.6)
rack-cors (~> 2.0) rack-cors (~> 2.0)
rack-test (~> 2.1) rack-test (~> 2.1)
rails (~> 7.0) rails (~> 6.1.7)
rails-controller-testing (~> 1.0) rails-controller-testing (~> 1.0)
rails-i18n (~> 7.0) rails-i18n (~> 6.0)
rails-settings-cached (~> 0.6)! rails-settings-cached (~> 0.6)!
rdf-normalize (~> 0.5) rdf-normalize (~> 0.5)
redcarpet (~> 3.6) redcarpet (~> 3.6)

@ -37,7 +37,7 @@ class InlineRenderer
private private
def preload_associations_for_status def preload_associations_for_status
ActiveRecord::Associations::Preloader.new(records: @object, associations: { ActiveRecord::Associations::Preloader.new.preload(@object, {
active_mentions: :account, active_mentions: :account,
reblog: { reblog: {

@ -16,7 +16,7 @@ class RSS::Channel < RSS::Element
end end
def last_build_date(date) def last_build_date(date)
append_element('lastBuildDate', date.to_fs(:rfc822)) append_element('lastBuildDate', date.to_formatted_s(:rfc822))
end end
def image(url, title, link) def image(url, title, link)

@ -20,7 +20,7 @@ class RSS::Item < RSS::Element
end end
def pub_date(date) def pub_date(date)
append_element('pubDate', date.to_fs(:rfc822)) append_element('pubDate', date.to_formatted_s(:rfc822))
end end
def description(str) def description(str)

@ -80,7 +80,7 @@ class Announcement < ApplicationRecord
end end
end end
ActiveRecord::Associations::Preloader.new(records: records, associations: :custom_emoji) ActiveRecord::Associations::Preloader.new.preload(records, :custom_emoji)
records records
end end

@ -122,7 +122,7 @@ module AccountSearch
tsquery = generate_query_for_search(terms) tsquery = generate_query_for_search(terms)
find_by_sql([BASIC_SEARCH_SQL, { limit: limit, offset: offset, tsquery: tsquery }]).tap do |records| find_by_sql([BASIC_SEARCH_SQL, { limit: limit, offset: offset, tsquery: tsquery }]).tap do |records|
ActiveRecord::Associations::Preloader.new(records: records, associations: :account_stat) ActiveRecord::Associations::Preloader.new.preload(records, :account_stat)
end end
end end
@ -131,7 +131,7 @@ module AccountSearch
sql_template = following ? ADVANCED_SEARCH_WITH_FOLLOWING : ADVANCED_SEARCH_WITHOUT_FOLLOWING sql_template = following ? ADVANCED_SEARCH_WITH_FOLLOWING : ADVANCED_SEARCH_WITHOUT_FOLLOWING
find_by_sql([sql_template, { id: account.id, limit: limit, offset: offset, tsquery: tsquery }]).tap do |records| find_by_sql([sql_template, { id: account.id, limit: limit, offset: offset, tsquery: tsquery }]).tap do |records|
ActiveRecord::Associations::Preloader.new(records: records, associations: :account_stat) ActiveRecord::Associations::Preloader.new.preload(records, :account_stat)
end end
end end

@ -4,41 +4,41 @@ module StatusSafeReblogInsert
extend ActiveSupport::Concern extend ActiveSupport::Concern
class_methods do class_methods do
# This patch overwrites the built-in ActiveRecord `_insert_record` method to # This is a hack to ensure that no reblogs of discarded statuses are created,
# ensure that no reblogs of discarded statuses are created, as this cannot be # as this cannot be enforced through database constraints the same way we do
# enforced through DB constraints the same way as reblogs of deleted statuses # for reblogs of deleted statuses.
# #
# We redefine the internal method responsible for issuing the `INSERT` # To achieve this, we redefine the internal method responsible for issuing
# statement and replace the `INSERT INTO ... VALUES ...` query with an `INSERT # the "INSERT" statement and replace the "INSERT INTO ... VALUES ..." query
# INTO ... SELECT ...` query with a `WHERE deleted_at IS NULL` clause on the # with an "INSERT INTO ... SELECT ..." query with a "WHERE deleted_at IS NULL"
# reblogged status to ensure consistency at the database level. # clause on the reblogged status to ensure consistency at the database level.
# #
# The code is kept similar to ActiveRecord::Persistence code and calls it # Otherwise, the code is kept as close as possible to ActiveRecord::Persistence
# directly when we are not handling a reblog. # code, and actually calls it if we are not handling a reblog.
def _insert_record(values) def _insert_record(values)
return super unless values.is_a?(Hash) && values['reblog_of_id']&.value.present? return super unless values.is_a?(Hash) && values['reblog_of_id'].present?
primary_key = self.primary_key primary_key = self.primary_key
primary_key_value = nil primary_key_value = nil
if prefetch_primary_key? && primary_key if primary_key
values[primary_key] ||= begin primary_key_value = values[primary_key]
if !primary_key_value && prefetch_primary_key?
primary_key_value = next_sequence_value primary_key_value = next_sequence_value
_default_attributes[primary_key].with_cast_value(primary_key_value) values[primary_key] = primary_key_value
end end
end end
# The following line departs from stock ActiveRecord # The following line is where we differ from stock ActiveRecord implementation
# Original code was:
# im.insert(values.transform_keys { |name| arel_table[name] })
# Instead, we use a custom builder when a reblog is happening:
im = _compile_reblog_insert(values) im = _compile_reblog_insert(values)
connection.insert(im, "#{self} Create", primary_key || false, primary_key_value).tap do |result| # Since we are using SELECT instead of VALUES, a non-error `nil` return is possible.
# Since we are using SELECT instead of VALUES, a non-error `nil` return is possible. # For our purposes, it's equivalent to a foreign key constraint violation
# For our purposes, it's equivalent to a foreign key constraint violation result = connection.insert(im, "#{self} Create", primary_key || false, primary_key_value)
raise ActiveRecord::InvalidForeignKey, "(reblog_of_id)=(#{values['reblog_of_id'].value}) is not present in table \"statuses\"" if result.nil? raise ActiveRecord::InvalidForeignKey, "(reblog_of_id)=(#{values['reblog_of_id']}) is not present in table \"statuses\"" if result.nil?
end
result
end end
def _compile_reblog_insert(values) def _compile_reblog_insert(values)
@ -54,9 +54,9 @@ module StatusSafeReblogInsert
binds = [] binds = []
reblog_bind = nil reblog_bind = nil
values.each do |name, attribute| values.each do |name, value|
attr = arel_table[name] attr = arel_table[name]
bind = predicate_builder.build_bind_attribute(attr.name, attribute.value) bind = predicate_builder.build_bind_attribute(attr.name, value)
im.columns << attr im.columns << attr
binds << bind binds << bind

@ -111,7 +111,7 @@ class Notification < ApplicationRecord
# Instead of using the usual `includes`, manually preload each type. # Instead of using the usual `includes`, manually preload each type.
# If polymorphic associations are loaded with the usual `includes`, other types of associations will be loaded more. # If polymorphic associations are loaded with the usual `includes`, other types of associations will be loaded more.
ActiveRecord::Associations::Preloader.new(records: grouped_notifications, associations: associations) ActiveRecord::Associations::Preloader.new.preload(grouped_notifications, associations)
end end
unique_target_statuses = notifications.filter_map(&:target_status).uniq unique_target_statuses = notifications.filter_map(&:target_status).uniq

@ -83,10 +83,7 @@ class InitialStateSerializer < ActiveModel::Serializer
def accounts def accounts
store = {} store = {}
ActiveRecord::Associations::Preloader.new( ActiveRecord::Associations::Preloader.new.preload([object.current_account, object.admin, object.owner, object.disabled_account, object.moved_to_account].compact, [:account_stat, :user, { moved_to_account: [:account_stat, :user] }])
records: [object.current_account, object.admin, object.owner, object.disabled_account, object.moved_to_account].compact,
associations: [:account_stat, :user, { moved_to_account: [:account_stat, :user] }]
)
store[object.current_account.id.to_s] = ActiveModelSerializers::SerializableResource.new(object.current_account, serializer: REST::AccountSerializer) if object.current_account store[object.current_account.id.to_s] = ActiveModelSerializers::SerializableResource.new(object.current_account, serializer: REST::AccountSerializer) if object.current_account
store[object.admin.id.to_s] = ActiveModelSerializers::SerializableResource.new(object.admin, serializer: REST::AccountSerializer) if object.admin store[object.admin.id.to_s] = ActiveModelSerializers::SerializableResource.new(object.admin, serializer: REST::AccountSerializer) if object.admin

@ -93,7 +93,7 @@ class AccountSearchService < BaseService
.objects .objects
.compact .compact
ActiveRecord::Associations::Preloader.new(records: records, associations: :account_stat) ActiveRecord::Associations::Preloader.new.preload(records, :account_stat)
records records
rescue Faraday::ConnectionFailed, Parslet::ParseFailed rescue Faraday::ConnectionFailed, Parslet::ParseFailed

@ -8,10 +8,7 @@ class BatchedRemoveStatusService < BaseService
# @param [Hash] options # @param [Hash] options
# @option [Boolean] :skip_side_effects Do not modify feeds and send updates to streaming API # @option [Boolean] :skip_side_effects Do not modify feeds and send updates to streaming API
def call(statuses, **options) def call(statuses, **options)
ActiveRecord::Associations::Preloader.new( ActiveRecord::Associations::Preloader.new.preload(statuses, options[:skip_side_effects] ? :reblogs : [:account, :tags, reblogs: :account])
records: statuses,
associations: options[:skip_side_effects] ? :reblogs : [:account, :tags, reblogs: :account]
)
statuses_and_reblogs = statuses.flat_map { |status| [status] + status.reblogs } statuses_and_reblogs = statuses.flat_map { |status| [status] + status.reblogs }
@ -20,10 +17,7 @@ class BatchedRemoveStatusService < BaseService
# rely on direct visibility statuses being relatively rare. # rely on direct visibility statuses being relatively rare.
statuses_with_account_conversations = statuses.select(&:direct_visibility?) statuses_with_account_conversations = statuses.select(&:direct_visibility?)
ActiveRecord::Associations::Preloader.new( ActiveRecord::Associations::Preloader.new.preload(statuses_with_account_conversations, [mentions: :account])
records: statuses_with_account_conversations,
associations: [mentions: :account]
)
statuses_with_account_conversations.each(&:unlink_from_conversations!) statuses_with_account_conversations.each(&:unlink_from_conversations!)

@ -57,15 +57,7 @@ require_relative '../lib/mastodon/redis_config'
module Mastodon module Mastodon
class Application < Rails::Application class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version. # Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.0 config.load_defaults 6.1
# TODO: Release a version which uses the 7.0 defaults as specified above,
# but preserves the 6.1 cache format as set below. In a subsequent change,
# remove this line setting to 6.1 cache format, and then release another version.
# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#new-activesupport-cache-serialization-format
# https://github.com/mastodon/mastodon/pull/24241#discussion_r1162890242
config.active_support.cache_format_version = 6.1
config.add_autoload_paths_to_load_path = false config.add_autoload_paths_to_load_path = false
# Settings in config/environments/* take precedence over those specified here. # Settings in config/environments/* take precedence over those specified here.

@ -1,10 +1,8 @@
require 'active_support/core_ext/integer/time'
Rails.application.configure do Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb. # Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded any time # In the development environment your application's code is reloaded on
# it changes. This slows down response time but is perfect for development # every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes. # since you don't have to restart the web server when you make code changes.
config.cache_classes = false config.cache_classes = false
@ -14,22 +12,13 @@ Rails.application.configure do
# Show full error reports. # Show full error reports.
config.consider_all_requests_local = true config.consider_all_requests_local = true
# Enable server timing
config.server_timing = true
# Enable/disable caching. By default caching is disabled. # Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching. # Run rails dev:cache to toggle caching.
if Rails.root.join('tmp', 'caching-dev.txt').exist? if Rails.root.join('tmp', 'caching-dev.txt').exist?
config.action_controller.perform_caching = true config.action_controller.perform_caching = true
config.action_controller.enable_fragment_cache_logging = true
config.cache_store = :redis_cache_store, REDIS_CACHE_PARAMS config.cache_store = :redis_cache_store, REDIS_CACHE_PARAMS
config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{2.days.to_i}",
}
else else
config.action_controller.perform_caching = false config.action_controller.perform_caching = false
config.cache_store = :null_store config.cache_store = :null_store
end end
@ -52,19 +41,12 @@ Rails.application.configure do
# Print deprecation notices to the Rails logger. # Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log config.active_support.deprecation = :log
# Raise exceptions for disallowed deprecations.
config.active_support.disallowed_deprecation = :raise
# Tell Active Support which deprecation messages to disallow.
config.active_support.disallowed_deprecation_warnings = []
# Raise an error on page load if there are pending migrations. # Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load config.active_record.migration_error = :page_load
# Highlight code that triggered database queries in logs.
config.active_record.verbose_query_logs = true
# Debug mode disables concatenation and preprocessing of assets. # Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true config.assets.debug = true
# Suppress logger output for asset requests. # Suppress logger output for asset requests.
@ -75,14 +57,12 @@ Rails.application.configure do
# Raises helpful error messages. # Raises helpful error messages.
config.assets.raise_runtime_errors = true config.assets.raise_runtime_errors = true
# Raises error for missing translations. # Raises error for missing translations
# config.i18n.raise_on_missing_translations = true # config.action_view.raise_on_missing_translations = true
# Annotate rendered view with file names.
# config.action_view.annotate_rendered_view_with_filenames = true
# Uncomment if you wish to allow Action Cable access from any origin. # Use an evented file watcher to asynchronously detect changes in source code,
# config.action_cable.disable_request_forgery_protection = true # routes, locales, etc. This feature depends on the listen gem.
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker
config.action_mailer.default_options = { from: 'notifications@localhost' } config.action_mailer.default_options = { from: 'notifications@localhost' }

@ -1,5 +1,3 @@
require "active_support/core_ext/integer/time"
Rails.application.configure do Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb. # Settings specified here will take precedence over those in config/application.rb.
@ -21,28 +19,20 @@ Rails.application.configure do
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files). # or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
# config.require_master_key = true # config.require_master_key = true
# Disable serving static files from the `/public` folder by default since ActiveSupport::Logger.new(STDOUT).tap do |logger|
# Apache or NGINX already handles this. logger.formatter = config.log_formatter
config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? config.logger = ActiveSupport::TaggedLogging.new(logger)
end
# Compress CSS using a preprocessor.
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed. # Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false config.assets.compile = false
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.asset_host = "http://assets.example.com"
# Specifies the header that your server uses for sending files. # Specifies the header that your server uses for sending files.
config.action_dispatch.x_sendfile_header = ENV['SENDFILE_HEADER'] if ENV['SENDFILE_HEADER'].present? config.action_dispatch.x_sendfile_header = ENV['SENDFILE_HEADER'] if ENV['SENDFILE_HEADER'].present?
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
# config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
# Allow to specify public IP of reverse proxy if it's needed # Allow to specify public IP of reverse proxy if it's needed
config.action_dispatch.trusted_proxies = ENV['TRUSTED_PROXY_IP'].split(/(?:\s*,\s*|\s+)/).map { |item| IPAddr.new(item) } if ENV['TRUSTED_PROXY_IP'].present? config.action_dispatch.trusted_proxies = ENV['TRUSTED_PROXY_IP'].split(/(?:\s*,\s*|\s+)/).map { |item| IPAddr.new(item) } if ENV['TRUSTED_PROXY_IP'].present?
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
config.force_ssl = true config.force_ssl = true
config.ssl_options = { config.ssl_options = {
redirect: { redirect: {
@ -50,8 +40,6 @@ Rails.application.configure do
} }
} }
# Include generic and useful information about system operation, but avoid logging too much
# information to avoid inadvertent exposure of personally identifiable information (PII).
# Use the lowest log level to ensure availability of diagnostic information # Use the lowest log level to ensure availability of diagnostic information
# when problems arise. # when problems arise.
config.log_level = ENV.fetch('RAILS_LOG_LEVEL', 'info').to_sym config.log_level = ENV.fetch('RAILS_LOG_LEVEL', 'info').to_sym
@ -62,12 +50,6 @@ Rails.application.configure do
# Use a different cache store in production. # Use a different cache store in production.
config.cache_store = :redis_cache_store, REDIS_CACHE_PARAMS config.cache_store = :redis_cache_store, REDIS_CACHE_PARAMS
# Use a real queuing backend for Active Job (and separate queues per environment).
# config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "mastodon_production"
config.action_mailer.perform_caching = false
# Ignore bad email addresses and do not raise email delivery errors. # Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false # config.action_mailer.raise_delivery_errors = false
@ -91,15 +73,6 @@ Rails.application.configure do
end end
end end
# Use a different logger for distributed setups.
# require "syslog/logger"
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name")
ActiveSupport::Logger.new(STDOUT).tap do |logger|
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
# Do not dump schema after migrations. # Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false config.active_record.dump_schema_after_migration = false

@ -1,32 +1,25 @@
require 'active_support/core_ext/integer/time'
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
Rails.application.configure do Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb. # Settings specified here will take precedence over those in config/application.rb.
# Turn false under Spring and add config.action_view.cache_template_loading = true. # The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true config.cache_classes = true
# Eager loading loads your whole application. When running a single test locally, # Do not eager load code on boot. This avoids loading your whole application
# this probably isn't necessary. It's a good idea to do in a continuous integration # just for the purpose of running a single test. If you are using a tool that
# system, or in some way before deploying your code. # preloads Rails for running tests, you may have to set it to true.
config.eager_load = ENV['CI'].present? config.eager_load = false
config.assets_digest = false config.assets.digest = false
# Configure public file server for tests with Cache-Control for performance.
config.public_file_server.enabled = true
config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{1.hour.to_i}"
}
# Show full error reports and disable caching. # Show full error reports and disable caching.
config.consider_all_requests_local = true config.consider_all_requests_local = true
config.action_controller.perform_caching = false config.action_controller.perform_caching = false
# The default store, file_store is shared by processes parallelly executed
# and should not be used.
config.cache_store = :memory_store config.cache_store = :memory_store
# Raise exceptions instead of rendering exception templates. # Raise exceptions instead of rendering exception templates.
@ -34,7 +27,6 @@ Rails.application.configure do
# Disable request forgery protection in test environment. # Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false config.action_controller.allow_forgery_protection = false
config.action_mailer.perform_caching = false config.action_mailer.perform_caching = false
config.action_mailer.default_options = { from: 'notifications@localhost' } config.action_mailer.default_options = { from: 'notifications@localhost' }
@ -54,8 +46,8 @@ Rails.application.configure do
config.x.vapid_private_key = vapid_key.private_key config.x.vapid_private_key = vapid_key.private_key
config.x.vapid_public_key = vapid_key.public_key config.x.vapid_public_key = vapid_key.public_key
# Raise exceptions for disallowed deprecations. # Raises error for missing translations
config.active_support.disallowed_deprecation = :raise # config.action_view.raise_on_missing_translations = true
config.i18n.default_locale = :en config.i18n.default_locale = :en
config.i18n.fallbacks = true config.i18n.fallbacks = true
@ -65,15 +57,6 @@ Rails.application.configure do
# Ref: https://github.com/mastodon/mastodon/issues/23644 # Ref: https://github.com/mastodon/mastodon/issues/23644
10.times { |i| Status.allocate.instance_variable_set(:"@ivar_#{i}", nil) } 10.times { |i| Status.allocate.instance_variable_set(:"@ivar_#{i}", nil) }
end end
# Tell Active Support which deprecation messages to disallow.
config.active_support.disallowed_deprecation_warnings = []
# Raises error for missing translations.
# config.i18n.raise_on_missing_translations = true
# Annotate rendered view with file names.
# config.action_view.annotate_rendered_view_with_filenames = true
end end
Paperclip::Attachment.default_options[:path] = Rails.root.join('spec', 'test_files', ':class', ':id_partition', ':style.:extension') Paperclip::Attachment.default_options[:path] = Rails.root.join('spec', 'test_files', ':class', ':id_partition', ':style.:extension')

@ -3,12 +3,11 @@
# Version of your assets, change this if you want to expire all your assets. # Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0' Rails.application.config.assets.version = '1.0'
# Add additional assets to the asset load path. # Add additional assets to the asset load path
# Rails.application.config.assets.paths << Emoji.images_path # Rails.application.config.assets.paths << 'node_modules'
# Precompile additional assets. # Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# folder are already added. # Rails.application.config.assets.precompile += %w()
# Rails.application.config.assets.precompile += %w( admin.js admin.css )
Rails.application.config.assets.initialize_on_precompile = true Rails.application.config.assets.initialize_on_precompile = true

@ -1,8 +1,4 @@
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# Configure parameters to be filtered from the log file. Use this to limit dissemination of # Configure sensitive parameters which will be filtered from the log file.
# sensitive information. See the ActiveSupport::ParameterFilter documentation for supported Rails.application.config.filter_parameters += [:password, :private_key, :public_key, :otp_attempt]
# notations and behaviors.
Rails.application.config.filter_parameters += [
:passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
]

@ -1,10 +0,0 @@
# frozen_string_literal: true
# TODO
# The Rails 7.0 framework default here is to set this true. However, we have a
# location in devise that redirects where we don't have an easy ability to
# override a method or set a config option, but where the redirect does not
# provide this option.
# https://github.com/heartcombo/devise/blob/v4.9.2/app/controllers/devise/confirmations_controller.rb#L28
# Once a solution is found, this line can be removed.
Rails.application.config.action_controller.raise_on_open_redirects = false

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[6.1].define(version: 2023_06_30_145300) do ActiveRecord::Schema.define(version: 2023_06_30_145300) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"

@ -44,7 +44,7 @@
"@formatjs/intl-pluralrules": "^5.2.2", "@formatjs/intl-pluralrules": "^5.2.2",
"@gamestdio/websocket": "^0.3.2", "@gamestdio/websocket": "^0.3.2",
"@github/webauthn-json": "^2.1.1", "@github/webauthn-json": "^2.1.1",
"@rails/ujs": "^7.0.6", "@rails/ujs": "^6.1.7",
"@reduxjs/toolkit": "^1.9.5", "@reduxjs/toolkit": "^1.9.5",
"abortcontroller-polyfill": "^1.7.5", "abortcontroller-polyfill": "^1.7.5",
"arrow-key-navigation": "^1.2.0", "arrow-key-navigation": "^1.2.0",

@ -1719,10 +1719,10 @@
resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.8.tgz#6b79032e760a0899cd4204710beede972a3a185f" resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.8.tgz#6b79032e760a0899cd4204710beede972a3a185f"
integrity sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A== integrity sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==
"@rails/ujs@^7.0.6": "@rails/ujs@^6.1.7":
version "7.0.6" version "6.1.7"
resolved "https://registry.yarnpkg.com/@rails/ujs/-/ujs-7.0.6.tgz#fd8937c92335f3da9495e07292511ad5f7547a6a" resolved "https://registry.yarnpkg.com/@rails/ujs/-/ujs-6.1.7.tgz#b09dc5b2105dd267e8374c47e4490240451dc7f6"
integrity sha512-s5v3AC6AywOIFMz0RIMW83Xc8FPIvKMkP3ZHFlM4ISNkhdUwP9HdhVtxxo6z3dIhe9vI0Our2A8kN/QpUV02Qg== integrity sha512-0e7WQ4LE/+LEfW2zfAw9ppsB6A8RmxbdAUPAF++UT80epY+7emuQDkKXmaK0a9lp6An50RvzezI0cIQjp1A58w==
"@redis/bloom@1.2.0": "@redis/bloom@1.2.0":
version "1.2.0" version "1.2.0"
@ -8759,7 +8759,12 @@ pg-cloudflare@^1.1.1:
resolved "https://registry.yarnpkg.com/pg-cloudflare/-/pg-cloudflare-1.1.1.tgz#e6d5833015b170e23ae819e8c5d7eaedb472ca98" resolved "https://registry.yarnpkg.com/pg-cloudflare/-/pg-cloudflare-1.1.1.tgz#e6d5833015b170e23ae819e8c5d7eaedb472ca98"
integrity sha512-xWPagP/4B6BgFO+EKz3JONXv3YDgvkbVrGw2mTo3D6tVDQRh1e7cqVGvyR3BE+eQgAvx1XhW/iEASj4/jCWl3Q== integrity sha512-xWPagP/4B6BgFO+EKz3JONXv3YDgvkbVrGw2mTo3D6tVDQRh1e7cqVGvyR3BE+eQgAvx1XhW/iEASj4/jCWl3Q==
pg-connection-string@^2.6.0, pg-connection-string@^2.6.1: pg-connection-string@^2.6.0:
version "2.6.1"
resolved "https://registry.yarnpkg.com/pg-connection-string/-/pg-connection-string-2.6.1.tgz#78c23c21a35dd116f48e12e23c0965e8d9e2cbfb"
integrity sha512-w6ZzNu6oMmIzEAYVw+RLK0+nqHPt8K3ZnknKi+g48Ak2pr3dtljJW3o+D/n2zzCG07Zoe9VOX3aiKpj+BN0pjg==
pg-connection-string@^2.6.1:
version "2.6.1" version "2.6.1"
resolved "https://registry.yarnpkg.com/pg-connection-string/-/pg-connection-string-2.6.1.tgz#78c23c21a35dd116f48e12e23c0965e8d9e2cbfb" resolved "https://registry.yarnpkg.com/pg-connection-string/-/pg-connection-string-2.6.1.tgz#78c23c21a35dd116f48e12e23c0965e8d9e2cbfb"
integrity sha512-w6ZzNu6oMmIzEAYVw+RLK0+nqHPt8K3ZnknKi+g48Ak2pr3dtljJW3o+D/n2zzCG07Zoe9VOX3aiKpj+BN0pjg== integrity sha512-w6ZzNu6oMmIzEAYVw+RLK0+nqHPt8K3ZnknKi+g48Ak2pr3dtljJW3o+D/n2zzCG07Zoe9VOX3aiKpj+BN0pjg==
@ -10831,7 +10836,6 @@ stringz@^2.1.0:
char-regex "^1.0.2" char-regex "^1.0.2"
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: "strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
name strip-ansi-cjs
version "6.0.1" version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==

Loading…
Cancel
Save