application.rb 4.9 KB

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