validate_configuration_roundtrip.rb 1.1 KB

123456789101112131415161718192021222324
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Mutations
  3. class Channel::Email::ValidateConfigurationRoundtrip < Channel::Email::BaseConfiguration
  4. description 'Validate an email channel configuration first sending and then fetching that same mail'
  5. argument :inbound_configuration, Gql::Types::Input::Channel::Email::InboundConfigurationInputType, 'Configuration to validate'
  6. argument :outbound_configuration, Gql::Types::Input::Channel::Email::OutboundConfigurationInputType, 'Configuration to validate'
  7. argument :email_address, String, description: 'Sender and recipient of verify email'
  8. field :success, Boolean, null: false, description: 'Was the validation successful?'
  9. def resolve(inbound_configuration:, outbound_configuration:, email_address:)
  10. internal_result = EmailHelper::Verify.email(
  11. inbound: map_type_to_config(inbound_configuration),
  12. outbound: map_type_to_config(outbound_configuration),
  13. sender: email_address,
  14. )
  15. map_probe_result(internal_result, field_prefix: internal_result[:source] || :inbound)
  16. end
  17. end
  18. end