action_cable_preferences.rb 1.1 KB

123456789101112131415161718192021222324252627282930
  1. # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. if ENV['ENABLE_EXPERIMENTAL_MOBILE_FRONTEND'] == 'true'
  3. if ENV['REDIS_URL'].present?
  4. Rails.application.config.action_cable.cable = {
  5. 'adapter' => 'redis',
  6. 'url' => ENV['REDIS_URL'],
  7. 'channel_prefix' => "zammad_#{Rails.env}"
  8. }
  9. Rails.logger.info 'Using the "Redis" adapter for ActionCable.'
  10. else
  11. if ActiveRecord::Base.connection_db_config.configuration_hash[:adapter] == 'mysql'
  12. raise 'Please provide a working redis instance via REDIS_URL - this is required on MySQL databases.'
  13. end
  14. # The 'postgresql' adapter does not work correctly in Capybara currently, so use
  15. # 'test' instead.
  16. if Rails.env.test?
  17. Rails.application.config.action_cable.cable = {
  18. 'adapter' => 'test',
  19. }
  20. Rails.logger.info 'Using the "test" adapter for ActionCable.'
  21. else
  22. Rails.application.config.action_cable.cable = {
  23. 'adapter' => 'postgresql',
  24. }
  25. Rails.logger.info 'Using the "PostgreSQL" adapter for ActionCable.'
  26. end
  27. end
  28. end