application.rb 4.3 KB

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