application.rb 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. # Please, add to the `ignore` list any other `lib` subdirectories that do
  56. # not contain `.rb` files, or that should not be reloaded or eager loaded.
  57. # Common ones are `templates`, `generators`, or `middleware`, for example.
  58. # config.autoload_lib(ignore: %w(assets tasks templates generators))
  59. # TODO: We should enable this eventually, but for now there are many things
  60. # in the wrong path from the perspective of zeitwerk.
  61. # Configuration for the application, engines, and railties goes here.
  62. #
  63. # These settings can be overridden in specific environments using the files
  64. # in config/environments, which are processed later.
  65. #
  66. # config.time_zone = "Central Time (US & Canada)"
  67. # config.eager_load_paths << Rails.root.join("extras")
  68. # config.paths.add File.join('app', 'api'), glob: File.join('**', '*.rb')
  69. # config.autoload_paths += Dir[Rails.root.join('app', 'api', '*')]
  70. config.active_job.queue_adapter = :sidekiq
  71. config.action_mailer.deliver_later_queue_name = 'mailers'
  72. config.action_mailer.preview_paths << Rails.root.join('spec', 'mailers', 'previews')
  73. # We use our own middleware for this
  74. config.public_file_server.enabled = false
  75. config.middleware.use PublicFileServerMiddleware if Rails.env.local? || ENV['RAILS_SERVE_STATIC_FILES'] == 'true'
  76. config.middleware.use Rack::Attack
  77. config.middleware.use Mastodon::RackMiddleware
  78. initializer :deprecator do |app|
  79. app.deprecators[:mastodon] = ActiveSupport::Deprecation.new('4.3', 'mastodon/mastodon')
  80. end
  81. config.to_prepare do
  82. Doorkeeper::AuthorizationsController.layout 'modal'
  83. Doorkeeper::AuthorizedApplicationsController.layout 'admin'
  84. Doorkeeper::Application.include ApplicationExtension
  85. Doorkeeper::AccessToken.include AccessTokenExtension
  86. Devise::FailureApp.include AbstractController::Callbacks
  87. Devise::FailureApp.include Localized
  88. end
  89. end
  90. end