application.rb 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. require_relative 'boot'
  3. require 'rails/all'
  4. require_relative 'issue_2656_workaround_for_rails_issue_33600'
  5. # Temporary Hack: skip vite build if ENABLE_EXPERIMENTAL_MOBILE_FRONTEND is not set.
  6. # This must be called before ViteRuby is loaded by Bundler.
  7. # TODO: Remove when this switch is not needed any more.
  8. if ENV['ENABLE_EXPERIMENTAL_MOBILE_FRONTEND'] != 'true'
  9. ENV['VITE_RUBY_SKIP_ASSETS_PRECOMPILE_EXTENSION'] = 'true'
  10. end
  11. # DO NOT REMOVE THIS LINE - see issue #2037
  12. Bundler.setup
  13. # Require the gems listed in Gemfile, including any gems
  14. # you've limited to :test, :development, or :production.
  15. Bundler.require(*Rails.groups)
  16. # EmailAddress gem clashes with EmailAddress model.
  17. # https://github.com/afair/email_address#namespace-conflict-resolution
  18. EmailAddressValidator = EmailAddress
  19. Object.send(:remove_const, :EmailAddress)
  20. # Only load gems for asset compilation if they are needed to avoid
  21. # having unneeded runtime dependencies like NodeJS.
  22. if ArgvHelper.argv.any? { |e| e.start_with? 'assets:' } || Rails.groups.exclude?('production')
  23. Bundler.load.current_dependencies.select do |dep|
  24. require dep.name if dep.groups.include?(:assets)
  25. end
  26. end
  27. module Zammad
  28. class Application < Rails::Application
  29. # Initialize configuration defaults for originally generated Rails version.
  30. config.load_defaults 6.1
  31. Rails.autoloaders.each do |autoloader|
  32. autoloader.ignore "#{config.root}/app/frontend"
  33. autoloader.do_not_eager_load "#{config.root}/lib/core_ext"
  34. autoloader.collapse "#{config.root}/lib/omniauth"
  35. autoloader.collapse "#{config.root}/lib/generators"
  36. autoloader.inflector.inflect(
  37. 'github_database' => 'GithubDatabase',
  38. 'otrs' => 'OTRS',
  39. 'db' => 'DB',
  40. )
  41. end
  42. # Settings in config/environments/* take precedence over those specified here.
  43. # Application configuration can go into files in config/initializers
  44. # -- all .rb files in that directory are automatically loaded after loading
  45. # the framework and any gems in your application.
  46. # Custom directories with classes and modules you want to be autoloadable.
  47. config.add_autoload_paths_to_load_path = false
  48. config.autoload_paths += %W[#{config.root}/lib]
  49. # zeitwerk:check will only check preloaded paths. To make sure that also lib/ gets validated,
  50. # add it to the eager_load_paths only if zeitwerk:check is running.
  51. config.eager_load_paths += %W[#{config.root}/lib] if ArgvHelper.argv[0].eql? 'zeitwerk:check'
  52. config.active_job.queue_adapter = :delayed_job
  53. config.active_record.use_yaml_unsafe_load = true
  54. # Use custom logger to log Thread id next to Process pid
  55. config.log_formatter = ::Logger::Formatter.new
  56. # REST api path
  57. config.api_path = '/api/v1'
  58. # define cache store
  59. if ENV['MEMCACHE_SERVERS'].present?
  60. require 'dalli' # Only load this gem when it is really used.
  61. config.cache_store = [:mem_cache_store, ENV['MEMCACHE_SERVERS'], { expires_in: 7.days }]
  62. else
  63. config.cache_store = [:zammad_file_store, Rails.root.join('tmp', "cache_file_store_#{Rails.env}"), { expires_in: 7.days }]
  64. end
  65. # define websocket session store
  66. # The web socket session store will fall back to localhost Redis usage if REDIS_URL is not set.
  67. # In this case, or if forced via ZAMMAD_WEBSOCKET_SESSION_STORE_FORCE_FS_BACKEND, the FS back end will be used.
  68. config.websocket_session_store = ENV['REDIS_URL'].present? && ENV['ZAMMAD_WEBSOCKET_SESSION_STORE_FORCE_FS_BACKEND'].blank? ? :redis : :file
  69. # default preferences by permission
  70. config.preferences_default_by_permission = {
  71. 'ticket.agent' => {
  72. notification_config: {
  73. matrix: {
  74. create: {
  75. criteria: {
  76. owned_by_me: true,
  77. owned_by_nobody: true,
  78. subscribed: true,
  79. no: false,
  80. },
  81. channel: {
  82. email: true,
  83. online: true,
  84. }
  85. },
  86. update: {
  87. criteria: {
  88. owned_by_me: true,
  89. owned_by_nobody: true,
  90. subscribed: true,
  91. no: false,
  92. },
  93. channel: {
  94. email: true,
  95. online: true,
  96. }
  97. },
  98. reminder_reached: {
  99. criteria: {
  100. owned_by_me: true,
  101. owned_by_nobody: false,
  102. subscribed: false,
  103. no: false,
  104. },
  105. channel: {
  106. email: true,
  107. online: true,
  108. }
  109. },
  110. escalation: {
  111. criteria: {
  112. owned_by_me: true,
  113. owned_by_nobody: false,
  114. subscribed: false,
  115. no: false,
  116. },
  117. channel: {
  118. email: true,
  119. online: true,
  120. }
  121. }
  122. }
  123. }
  124. }
  125. }
  126. end
  127. end