connection.rb 1.0 KB

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