email_notification.rb 984 B

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