application.rb 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. require_relative 'boot'
  2. require 'rails'
  3. require 'active_record/railtie'
  4. #require 'active_storage/engine'
  5. require 'action_controller/railtie'
  6. require 'action_view/railtie'
  7. require 'action_mailer/railtie'
  8. require 'active_job/railtie'
  9. #require 'action_cable/engine'
  10. #require 'action_mailbox/engine'
  11. #require 'action_text/engine'
  12. #require 'rails/test_unit/railtie'
  13. require 'sprockets/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/transcoder'
  27. require_relative '../lib/paperclip/type_corrector'
  28. require_relative '../lib/paperclip/response_with_limit_adapter'
  29. require_relative '../lib/terrapin/multi_pipe_extensions'
  30. require_relative '../lib/mastodon/snowflake'
  31. require_relative '../lib/mastodon/version'
  32. require_relative '../lib/mastodon/rack_middleware'
  33. require_relative '../lib/public_file_server_middleware'
  34. require_relative '../lib/devise/two_factor_ldap_authenticatable'
  35. require_relative '../lib/devise/two_factor_pam_authenticatable'
  36. require_relative '../lib/chewy/strategy/mastodon'
  37. require_relative '../lib/chewy/strategy/bypass_with_warning'
  38. require_relative '../lib/webpacker/manifest_extensions'
  39. require_relative '../lib/webpacker/helper_extensions'
  40. require_relative '../lib/rails/engine_extensions'
  41. require_relative '../lib/active_record/database_tasks_extensions'
  42. require_relative '../lib/active_record/batches'
  43. require_relative '../lib/simple_navigation/item_extensions'
  44. Dotenv::Railtie.load
  45. Bundler.require(:pam_authentication) if ENV['PAM_ENABLED'] == 'true'
  46. require_relative '../lib/mastodon/redis_config'
  47. module Mastodon
  48. class Application < Rails::Application
  49. # Initialize configuration defaults for originally generated Rails version.
  50. config.load_defaults 6.1
  51. config.add_autoload_paths_to_load_path = false
  52. # Settings in config/environments/* take precedence over those specified here.
  53. # Application configuration should go into files in config/initializers
  54. # -- all .rb files in that directory are automatically loaded.
  55. # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
  56. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
  57. # config.time_zone = 'Central Time (US & Canada)'
  58. # All translations from config/locales/*.rb,yml are auto loaded.
  59. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
  60. config.i18n.available_locales = [
  61. :af,
  62. :an,
  63. :ar,
  64. :ast,
  65. :be,
  66. :bg,
  67. :bn,
  68. :br,
  69. :bs,
  70. :ca,
  71. :ckb,
  72. :co,
  73. :cs,
  74. :cy,
  75. :da,
  76. :de,
  77. :el,
  78. :en,
  79. :'en-GB',
  80. :eo,
  81. :es,
  82. :'es-AR',
  83. :'es-MX',
  84. :et,
  85. :eu,
  86. :fa,
  87. :fi,
  88. :fo,
  89. :fr,
  90. :'fr-QC',
  91. :fy,
  92. :ga,
  93. :gd,
  94. :gl,
  95. :he,
  96. :hi,
  97. :hr,
  98. :hu,
  99. :hy,
  100. :id,
  101. :ig,
  102. :io,
  103. :is,
  104. :it,
  105. :ja,
  106. :ka,
  107. :kab,
  108. :kk,
  109. :kn,
  110. :ko,
  111. :ku,
  112. :kw,
  113. :la,
  114. :lt,
  115. :lv,
  116. :mk,
  117. :ml,
  118. :mr,
  119. :ms,
  120. :my,
  121. :nl,
  122. :nn,
  123. :no,
  124. :oc,
  125. :pa,
  126. :pl,
  127. :'pt-BR',
  128. :'pt-PT',
  129. :ro,
  130. :ru,
  131. :sa,
  132. :sc,
  133. :sco,
  134. :si,
  135. :sk,
  136. :sl,
  137. :sq,
  138. :sr,
  139. :'sr-Latn',
  140. :sv,
  141. :szl,
  142. :ta,
  143. :tai,
  144. :te,
  145. :th,
  146. :tr,
  147. :tt,
  148. :ug,
  149. :uk,
  150. :ur,
  151. :vi,
  152. :zgh,
  153. :'zh-CN',
  154. :'zh-HK',
  155. :'zh-TW',
  156. ]
  157. config.i18n.default_locale = begin
  158. custom_default_locale = ENV['DEFAULT_LOCALE']&.to_sym
  159. if config.i18n.available_locales.include?(custom_default_locale)
  160. custom_default_locale
  161. else
  162. :en
  163. end
  164. end
  165. # config.paths.add File.join('app', 'api'), glob: File.join('**', '*.rb')
  166. # config.autoload_paths += Dir[Rails.root.join('app', 'api', '*')]
  167. config.active_job.queue_adapter = :sidekiq
  168. config.action_mailer.deliver_later_queue_name = 'mailers'
  169. # We use our own middleware for this
  170. config.public_file_server.enabled = false
  171. config.middleware.use PublicFileServerMiddleware if Rails.env.development? || ENV['RAILS_SERVE_STATIC_FILES'] == 'true'
  172. config.middleware.use Rack::Attack
  173. config.middleware.use Mastodon::RackMiddleware
  174. config.to_prepare do
  175. Doorkeeper::AuthorizationsController.layout 'modal'
  176. Doorkeeper::AuthorizedApplicationsController.layout 'admin'
  177. Doorkeeper::Application.send :include, ApplicationExtension
  178. Doorkeeper::AccessToken.send :include, AccessTokenExtension
  179. Devise::FailureApp.send :include, AbstractController::Callbacks
  180. Devise::FailureApp.send :include, Localized
  181. end
  182. end
  183. end