application.rb 5.3 KB

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