application.rb 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. # frozen_string_literal: true
  2. require_relative 'boot'
  3. require 'rails'
  4. require 'active_record/railtie'
  5. # require 'active_storage/engine'
  6. require 'action_controller/railtie'
  7. require 'action_view/railtie'
  8. require 'action_mailer/railtie'
  9. require 'active_job/railtie'
  10. # require 'action_cable/engine'
  11. # require 'action_mailbox/engine'
  12. # require 'action_text/engine'
  13. # require 'rails/test_unit/railtie'
  14. # Used to be implicitly required in action_mailbox/engine
  15. require 'mail'
  16. # Require the gems listed in Gemfile, including any gems
  17. # you've limited to :test, :development, or :production.
  18. Bundler.require(*Rails.groups)
  19. require_relative '../lib/exceptions'
  20. require_relative '../lib/sanitize_ext/sanitize_config'
  21. require_relative '../lib/redis/namespace_extensions'
  22. require_relative '../lib/paperclip/url_generator_extensions'
  23. require_relative '../lib/paperclip/attachment_extensions'
  24. require_relative '../lib/paperclip/lazy_thumbnail'
  25. require_relative '../lib/paperclip/gif_transcoder'
  26. require_relative '../lib/paperclip/media_type_spoof_detector_extensions'
  27. require_relative '../lib/paperclip/transcoder'
  28. require_relative '../lib/paperclip/type_corrector'
  29. require_relative '../lib/paperclip/response_with_limit_adapter'
  30. require_relative '../lib/terrapin/multi_pipe_extensions'
  31. require_relative '../lib/mastodon/snowflake'
  32. require_relative '../lib/mastodon/version'
  33. require_relative '../lib/mastodon/rack_middleware'
  34. require_relative '../lib/public_file_server_middleware'
  35. require_relative '../lib/devise/strategies/two_factor_ldap_authenticatable'
  36. require_relative '../lib/devise/strategies/two_factor_pam_authenticatable'
  37. require_relative '../lib/chewy/settings_extensions'
  38. require_relative '../lib/chewy/index_extensions'
  39. require_relative '../lib/chewy/strategy/mastodon'
  40. require_relative '../lib/chewy/strategy/bypass_with_warning'
  41. require_relative '../lib/webpacker/manifest_extensions'
  42. require_relative '../lib/webpacker/helper_extensions'
  43. require_relative '../lib/rails/engine_extensions'
  44. require_relative '../lib/active_record/database_tasks_extensions'
  45. require_relative '../lib/active_record/batches'
  46. require_relative '../lib/simple_navigation/item_extensions'
  47. require_relative '../lib/http_extensions'
  48. Dotenv::Railtie.load
  49. Bundler.require(:pam_authentication) if ENV['PAM_ENABLED'] == 'true'
  50. require_relative '../lib/mastodon/redis_config'
  51. module Mastodon
  52. class Application < Rails::Application
  53. # Initialize configuration defaults for originally generated Rails version.
  54. config.load_defaults 7.0
  55. # TODO: Release a version which uses the 7.0 defaults as specified above,
  56. # but preserves the 6.1 cache format as set below. In a subsequent change,
  57. # remove this line setting to 6.1 cache format, and then release another version.
  58. # https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#new-activesupport-cache-serialization-format
  59. # https://github.com/mastodon/mastodon/pull/24241#discussion_r1162890242
  60. config.active_support.cache_format_version = 6.1
  61. # Please, add to the `ignore` list any other `lib` subdirectories that do
  62. # not contain `.rb` files, or that should not be reloaded or eager loaded.
  63. # Common ones are `templates`, `generators`, or `middleware`, for example.
  64. # config.autoload_lib(ignore: %w(assets tasks templates generators))
  65. # TODO: We should enable this eventually, but for now there are many things
  66. # in the wrong path from the perspective of zeitwerk.
  67. # Configuration for the application, engines, and railties goes here.
  68. #
  69. # These settings can be overridden in specific environments using the files
  70. # in config/environments, which are processed later.
  71. #
  72. # config.time_zone = "Central Time (US & Canada)"
  73. # config.eager_load_paths << Rails.root.join("extras")
  74. # config.paths.add File.join('app', 'api'), glob: File.join('**', '*.rb')
  75. # config.autoload_paths += Dir[Rails.root.join('app', 'api', '*')]
  76. config.active_job.queue_adapter = :sidekiq
  77. config.action_mailer.deliver_later_queue_name = 'mailers'
  78. config.action_mailer.preview_paths << Rails.root.join('spec', 'mailers', 'previews')
  79. # We use our own middleware for this
  80. config.public_file_server.enabled = false
  81. config.middleware.use PublicFileServerMiddleware if Rails.env.local? || ENV['RAILS_SERVE_STATIC_FILES'] == 'true'
  82. config.middleware.use Rack::Attack
  83. config.middleware.use Mastodon::RackMiddleware
  84. initializer :deprecator do |app|
  85. app.deprecators[:mastodon] = ActiveSupport::Deprecation.new('4.3', 'mastodon/mastodon')
  86. end
  87. config.to_prepare do
  88. Doorkeeper::AuthorizationsController.layout 'modal'
  89. Doorkeeper::AuthorizedApplicationsController.layout 'admin'
  90. Doorkeeper::Application.include ApplicationExtension
  91. Doorkeeper::AccessToken.include AccessTokenExtension
  92. Devise::FailureApp.include AbstractController::Callbacks
  93. Devise::FailureApp.include Localized
  94. end
  95. end
  96. end