connection.rb 801 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. class Sequencer::Unit::Exchange::Connection < Sequencer::Unit::Common::Provider::Fallback
  3. uses :ews_config
  4. provides :ews_connection
  5. private
  6. def ews_connection
  7. require 'viewpoint' # Only load this gem when it is really used.
  8. Viewpoint::EWSClient.new(
  9. config[:endpoint],
  10. config[:user],
  11. config[:password],
  12. additional_opts
  13. )
  14. end
  15. def config
  16. @config ||= begin
  17. ews_config || ::Import::Exchange.config
  18. end
  19. end
  20. def additional_opts
  21. @additional_opts ||= begin
  22. http_opts
  23. end
  24. end
  25. def http_opts
  26. return {} if config[:disable_ssl_verify].blank?
  27. {
  28. http_opts: {
  29. ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE
  30. }
  31. }
  32. end
  33. end