2023-07-12 17:47:08 +10:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-18 01:56:23 +10:00
|
|
|
require_relative 'boot'
|
2016-02-21 08:53:20 +11:00
|
|
|
|
2021-09-14 02:59:56 +10:00
|
|
|
require 'rails'
|
|
|
|
|
|
|
|
require 'active_record/railtie'
|
2023-10-04 00:24:12 +11:00
|
|
|
# require 'active_storage/engine'
|
2021-09-14 02:59:56 +10:00
|
|
|
require 'action_controller/railtie'
|
|
|
|
require 'action_view/railtie'
|
|
|
|
require 'action_mailer/railtie'
|
|
|
|
require 'active_job/railtie'
|
2023-10-04 00:24:12 +11:00
|
|
|
# require 'action_cable/engine'
|
|
|
|
# require 'action_mailbox/engine'
|
|
|
|
# require 'action_text/engine'
|
|
|
|
# require 'rails/test_unit/railtie'
|
2021-09-14 02:59:56 +10:00
|
|
|
|
|
|
|
# Used to be implicitly required in action_mailbox/engine
|
|
|
|
require 'mail'
|
2016-02-21 08:53:20 +11:00
|
|
|
|
|
|
|
# Require the gems listed in Gemfile, including any gems
|
|
|
|
# you've limited to :test, :development, or :production.
|
|
|
|
Bundler.require(*Rails.groups)
|
|
|
|
|
2021-03-19 12:42:43 +11:00
|
|
|
require_relative '../lib/exceptions'
|
|
|
|
require_relative '../lib/sanitize_ext/sanitize_config'
|
2020-07-02 03:05:21 +10:00
|
|
|
require_relative '../lib/redis/namespace_extensions'
|
2020-03-27 01:09:16 +11:00
|
|
|
require_relative '../lib/paperclip/url_generator_extensions'
|
2020-03-09 09:56:18 +11:00
|
|
|
require_relative '../lib/paperclip/attachment_extensions'
|
2024-06-06 05:15:39 +10:00
|
|
|
|
2017-03-05 08:17:10 +11:00
|
|
|
require_relative '../lib/paperclip/gif_transcoder'
|
2023-07-06 23:05:05 +10:00
|
|
|
require_relative '../lib/paperclip/media_type_spoof_detector_extensions'
|
2021-05-06 03:44:01 +10:00
|
|
|
require_relative '../lib/paperclip/transcoder'
|
2019-06-20 18:52:36 +10:00
|
|
|
require_relative '../lib/paperclip/type_corrector'
|
2020-07-01 07:58:02 +10:00
|
|
|
require_relative '../lib/paperclip/response_with_limit_adapter'
|
2021-05-06 03:44:01 +10:00
|
|
|
require_relative '../lib/terrapin/multi_pipe_extensions'
|
2017-10-09 02:34:34 +11:00
|
|
|
require_relative '../lib/mastodon/snowflake'
|
2017-04-21 11:30:59 +10:00
|
|
|
require_relative '../lib/mastodon/version'
|
2022-04-29 01:47:34 +10:00
|
|
|
require_relative '../lib/mastodon/rack_middleware'
|
2023-03-16 12:55:54 +11:00
|
|
|
require_relative '../lib/public_file_server_middleware'
|
2023-11-29 21:10:21 +11:00
|
|
|
require_relative '../lib/devise/strategies/two_factor_ldap_authenticatable'
|
|
|
|
require_relative '../lib/devise/strategies/two_factor_pam_authenticatable'
|
2024-05-15 03:54:28 +10:00
|
|
|
require_relative '../lib/elasticsearch/client_extensions'
|
2023-08-15 01:46:16 +10:00
|
|
|
require_relative '../lib/chewy/settings_extensions'
|
|
|
|
require_relative '../lib/chewy/index_extensions'
|
2022-05-19 07:29:14 +10:00
|
|
|
require_relative '../lib/chewy/strategy/mastodon'
|
2023-04-03 23:05:39 +10:00
|
|
|
require_relative '../lib/chewy/strategy/bypass_with_warning'
|
2020-11-06 21:56:31 +11:00
|
|
|
require_relative '../lib/webpacker/manifest_extensions'
|
|
|
|
require_relative '../lib/webpacker/helper_extensions'
|
2021-02-11 12:11:30 +11:00
|
|
|
require_relative '../lib/rails/engine_extensions'
|
2024-05-30 22:24:29 +10:00
|
|
|
require_relative '../lib/action_dispatch/remote_ip_extensions'
|
2024-06-20 02:59:37 +10:00
|
|
|
require_relative '../lib/stoplight/redis_data_store_extensions'
|
2021-03-19 12:43:13 +11:00
|
|
|
require_relative '../lib/active_record/database_tasks_extensions'
|
2021-04-12 11:35:58 +10:00
|
|
|
require_relative '../lib/active_record/batches'
|
2024-06-03 18:35:59 +10:00
|
|
|
require_relative '../lib/active_record/with_recursive'
|
|
|
|
require_relative '../lib/arel/union_parenthesizing'
|
2022-07-05 10:41:40 +10:00
|
|
|
require_relative '../lib/simple_navigation/item_extensions'
|
2017-03-05 08:17:10 +11:00
|
|
|
|
2018-03-20 06:08:56 +11:00
|
|
|
Bundler.require(:pam_authentication) if ENV['PAM_ENABLED'] == 'true'
|
|
|
|
|
2016-02-21 08:53:20 +11:00
|
|
|
module Mastodon
|
|
|
|
class Application < Rails::Application
|
2018-01-20 06:56:47 +11:00
|
|
|
# Initialize configuration defaults for originally generated Rails version.
|
2024-06-10 16:32:20 +10:00
|
|
|
config.load_defaults 7.1
|
2023-07-13 17:36:07 +10:00
|
|
|
|
2024-06-10 16:32:20 +10:00
|
|
|
# Explicitly set the cache format version to align with Rails version
|
|
|
|
config.active_support.cache_format_version = 7.1
|
2024-01-06 08:57:47 +11:00
|
|
|
|
2023-10-26 00:56:09 +11:00
|
|
|
# Please, add to the `ignore` list any other `lib` subdirectories that do
|
|
|
|
# not contain `.rb` files, or that should not be reloaded or eager loaded.
|
|
|
|
# Common ones are `templates`, `generators`, or `middleware`, for example.
|
|
|
|
# config.autoload_lib(ignore: %w(assets tasks templates generators))
|
|
|
|
# TODO: We should enable this eventually, but for now there are many things
|
|
|
|
# in the wrong path from the perspective of zeitwerk.
|
2018-01-20 06:56:47 +11:00
|
|
|
|
2023-10-26 00:56:09 +11:00
|
|
|
# Configuration for the application, engines, and railties goes here.
|
|
|
|
#
|
|
|
|
# These settings can be overridden in specific environments using the files
|
|
|
|
# in config/environments, which are processed later.
|
|
|
|
#
|
|
|
|
# config.time_zone = "Central Time (US & Canada)"
|
|
|
|
# config.eager_load_paths << Rails.root.join("extras")
|
2016-02-21 08:53:20 +11:00
|
|
|
|
2016-10-15 08:10:07 +11:00
|
|
|
# config.paths.add File.join('app', 'api'), glob: File.join('**', '*.rb')
|
|
|
|
# config.autoload_paths += Dir[Rails.root.join('app', 'api', '*')]
|
2016-03-07 22:42:33 +11:00
|
|
|
|
2016-03-25 12:50:48 +11:00
|
|
|
config.active_job.queue_adapter = :sidekiq
|
2023-07-22 05:12:57 +10:00
|
|
|
|
2022-11-10 12:31:09 +11:00
|
|
|
config.action_mailer.deliver_later_queue_name = 'mailers'
|
2023-10-24 04:58:29 +11:00
|
|
|
config.action_mailer.preview_paths << Rails.root.join('spec', 'mailers', 'previews')
|
2016-03-25 12:50:48 +11:00
|
|
|
|
2023-03-16 12:55:54 +11:00
|
|
|
# We use our own middleware for this
|
|
|
|
config.public_file_server.enabled = false
|
|
|
|
|
2023-11-07 21:44:15 +11:00
|
|
|
config.middleware.use PublicFileServerMiddleware if Rails.env.local? || ENV['RAILS_SERVE_STATIC_FILES'] == 'true'
|
2016-03-20 00:57:30 +11:00
|
|
|
config.middleware.use Rack::Attack
|
2022-04-29 01:47:34 +10:00
|
|
|
config.middleware.use Mastodon::RackMiddleware
|
2016-08-25 01:56:44 +10:00
|
|
|
|
2023-10-24 04:58:29 +11:00
|
|
|
initializer :deprecator do |app|
|
|
|
|
app.deprecators[:mastodon] = ActiveSupport::Deprecation.new('4.3', 'mastodon/mastodon')
|
|
|
|
end
|
|
|
|
|
2024-04-30 23:00:39 +10:00
|
|
|
config.before_configuration do
|
|
|
|
require 'mastodon/redis_config'
|
2024-06-06 05:15:39 +10:00
|
|
|
|
|
|
|
config.x.use_vips = ENV['MASTODON_USE_LIBVIPS'] == 'true'
|
|
|
|
|
|
|
|
if config.x.use_vips
|
|
|
|
require_relative '../lib/paperclip/vips_lazy_thumbnail'
|
|
|
|
else
|
|
|
|
require_relative '../lib/paperclip/lazy_thumbnail'
|
|
|
|
end
|
2024-04-30 23:00:39 +10:00
|
|
|
end
|
|
|
|
|
2016-10-03 08:46:25 +11:00
|
|
|
config.to_prepare do
|
2017-08-05 12:24:58 +10:00
|
|
|
Doorkeeper::AuthorizationsController.layout 'modal'
|
2017-01-28 13:56:10 +11:00
|
|
|
Doorkeeper::AuthorizedApplicationsController.layout 'admin'
|
2023-07-12 18:02:32 +10:00
|
|
|
Doorkeeper::Application.include ApplicationExtension
|
2024-06-11 18:50:51 +10:00
|
|
|
Doorkeeper::AccessGrant.include AccessGrantExtension
|
2023-07-12 18:02:32 +10:00
|
|
|
Doorkeeper::AccessToken.include AccessTokenExtension
|
2024-07-26 18:53:10 +10:00
|
|
|
Doorkeeper::OAuth::PreAuthorization.include OauthPreAuthorizationExtension
|
2023-07-12 18:02:32 +10:00
|
|
|
Devise::FailureApp.include AbstractController::Callbacks
|
|
|
|
Devise::FailureApp.include Localized
|
2016-10-03 08:46:25 +11:00
|
|
|
end
|
2016-02-21 08:53:20 +11:00
|
|
|
end
|
|
|
|
end
|