email_inbound.rb 868 B

123456789101112131415161718192021222324252627282930313233
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class FormUpdater::Updater::GuidedSetup::EmailInbound < FormUpdater::Updater
  3. def authorized?
  4. current_user.permissions?('admin.wizard')
  5. end
  6. def resolve
  7. if meta[:initial]
  8. result['adapter'] = email_inbound_adapters
  9. end
  10. super
  11. end
  12. private
  13. def available_adapters
  14. @available_adapters ||= EmailHelper.available_driver
  15. end
  16. def email_inbound_adapters
  17. {
  18. initialValue: available_adapters[:inbound].find { |adapter| adapter[0].to_s.casecmp?('imap') }&.first.to_s,
  19. options: available_adapters[:inbound].each_with_object([]) do |adapter, options|
  20. options << {
  21. value: adapter[0].to_s,
  22. label: adapter[1],
  23. }
  24. end,
  25. }
  26. end
  27. end