application.rb 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. # Copyright (C) 2012-2022 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. # Only load gems for asset compilation if they are needed to avoid
  17. # having unneeded runtime dependencies like NodeJS.
  18. if ArgvHelper.argv.include?('assets:precompile') || Rails.groups.exclude?('production')
  19. Bundler.load.current_dependencies.select do |dep|
  20. require dep.name if dep.groups.include?(:assets)
  21. end
  22. end
  23. module Zammad
  24. class Application < Rails::Application
  25. # Initialize configuration defaults for originally generated Rails version.
  26. config.load_defaults 6.1
  27. Rails.autoloaders.each do |autoloader|
  28. autoloader.ignore "#{config.root}/app/frontend"
  29. autoloader.do_not_eager_load "#{config.root}/lib/core_ext"
  30. autoloader.collapse "#{config.root}/lib/omniauth"
  31. autoloader.inflector.inflect(
  32. 'github_database' => 'GithubDatabase',
  33. 'otrs' => 'OTRS',
  34. 'db' => 'DB',
  35. )
  36. end
  37. # Settings in config/environments/* take precedence over those specified here.
  38. # Application configuration can go into files in config/initializers
  39. # -- all .rb files in that directory are automatically loaded after loading
  40. # the framework and any gems in your application.
  41. # Custom directories with classes and modules you want to be autoloadable.
  42. config.add_autoload_paths_to_load_path = false
  43. config.autoload_paths += %W[#{config.root}/lib]
  44. # zeitwerk:check will only check preloaded paths. To make sure that also lib/ gets validated,
  45. # add it to the eager_load_paths only if zeitwerk:check is running.
  46. config.eager_load_paths += %W[#{config.root}/lib] if ArgvHelper.argv[0].eql? 'zeitwerk:check'
  47. config.active_job.queue_adapter = :delayed_job
  48. # Use custom logger to log Thread id next to Process pid
  49. config.log_formatter = ::Logger::Formatter.new
  50. # REST api path
  51. config.api_path = '/api/v1'
  52. # define cache store
  53. if ENV['MEMCACHE_SERVERS'].present?
  54. require 'dalli' # Only load this gem when it is really used.
  55. config.cache_store = [:mem_cache_store, ENV['MEMCACHE_SERVERS'], { expires_in: 7.days }]
  56. else
  57. config.cache_store = [:zammad_file_store, Rails.root.join('tmp', "cache_file_store_#{Rails.env}"), { expires_in: 7.days }]
  58. end
  59. # define websocket session store
  60. config.websocket_session_store = if ENV['REDIS_URL'].present?
  61. :redis
  62. else
  63. :file
  64. end
  65. # default preferences by permission
  66. config.preferences_default_by_permission = {
  67. 'ticket.agent' => {
  68. notification_config: {
  69. matrix: {
  70. create: {
  71. criteria: {
  72. owned_by_me: true,
  73. owned_by_nobody: true,
  74. subscribed: true,
  75. no: false,
  76. },
  77. channel: {
  78. email: true,
  79. online: true,
  80. }
  81. },
  82. update: {
  83. criteria: {
  84. owned_by_me: true,
  85. owned_by_nobody: true,
  86. subscribed: true,
  87. no: false,
  88. },
  89. channel: {
  90. email: true,
  91. online: true,
  92. }
  93. },
  94. reminder_reached: {
  95. criteria: {
  96. owned_by_me: true,
  97. owned_by_nobody: false,
  98. subscribed: false,
  99. no: false,
  100. },
  101. channel: {
  102. email: true,
  103. online: true,
  104. }
  105. },
  106. escalation: {
  107. criteria: {
  108. owned_by_me: true,
  109. owned_by_nobody: false,
  110. subscribed: false,
  111. no: false,
  112. },
  113. channel: {
  114. email: true,
  115. online: true,
  116. }
  117. }
  118. }
  119. }
  120. }
  121. }
  122. end
  123. end