Sha256: 8e6fec19488d80c964ec18248703424431fbec9126b30d3b6a47a6945d8ae2ec

Contents?: true

Size: 1.18 KB

Versions: 21

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

require "ostruct"

module NeetoCommonsBackend
  module Initializers
    class << self
      def neeto_mail_interceptor
        intercept_secrets = Rails.application.secrets.mail_interceptor

        if Rails.env.staging?
          cleanup = proc { |n| n.split(",").map(&:strip) }

          interceptor = NeetoMailInterceptor::Interceptor.new(
            forward_emails_to: cleanup.call(intercept_secrets[:forward_emails_to] || ""),
            deliver_emails_to: cleanup.call(intercept_secrets[:whitelisted_emails] || "")
          )
          ActionMailer::Base.register_interceptor(interceptor)
        elsif Rails.env.production?
          interceptor = NeetoMailInterceptor::Interceptor.new(
            env: OpenStruct.new(name: Rails.env, intercept?: true),
            only_intercept: ["@example.com", "@example.net", "@neetoauth.com", "nitrohelp.com"]
          )
          ActionMailer::Base.register_interceptor(interceptor)
        end

        if Rails.application.secrets.zerobounce_api_key.present?
          NeetoMailInterceptor.configure do |config|
            config.enable_zerobounce_validation = true
          end
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
neeto-commons-backend-1.0.109 lib/neeto_commons_backend/initializers/neeto_mail_interceptor.rb
neeto-commons-backend-1.0.108 lib/neeto_commons_backend/initializers/neeto_mail_interceptor.rb
neeto-commons-backend-1.0.107 lib/neeto_commons_backend/initializers/neeto_mail_interceptor.rb
neeto-commons-backend-1.0.106 lib/neeto_commons_backend/initializers/neeto_mail_interceptor.rb
neeto-commons-backend-1.0.105 lib/neeto_commons_backend/initializers/neeto_mail_interceptor.rb
neeto-commons-backend-1.0.104 lib/neeto_commons_backend/initializers/neeto_mail_interceptor.rb
neeto-commons-backend-1.0.103 lib/neeto_commons_backend/initializers/neeto_mail_interceptor.rb
neeto-commons-backend-1.0.102 lib/neeto_commons_backend/initializers/neeto_mail_interceptor.rb
neeto-commons-backend-1.0.101 lib/neeto_commons_backend/initializers/neeto_mail_interceptor.rb
neeto-commons-backend-1.0.100 lib/neeto_commons_backend/initializers/neeto_mail_interceptor.rb
neeto-commons-backend-1.0.99 lib/neeto_commons_backend/initializers/neeto_mail_interceptor.rb
neeto-commons-backend-1.0.98 lib/neeto_commons_backend/initializers/neeto_mail_interceptor.rb
neeto-commons-backend-1.0.97 lib/neeto_commons_backend/initializers/neeto_mail_interceptor.rb
neeto-commons-backend-1.0.96 lib/neeto_commons_backend/initializers/neeto_mail_interceptor.rb
neeto-commons-backend-1.0.95 lib/neeto_commons_backend/initializers/neeto_mail_interceptor.rb
neeto-commons-backend-1.0.94 lib/neeto_commons_backend/initializers/neeto_mail_interceptor.rb
neeto-commons-backend-1.0.93 lib/neeto_commons_backend/initializers/neeto_mail_interceptor.rb
neeto-commons-backend-1.0.92 lib/neeto_commons_backend/initializers/neeto_mail_interceptor.rb
neeto-commons-backend-1.0.91 lib/neeto_commons_backend/initializers/neeto_mail_interceptor.rb
neeto-commons-backend-1.0.90 lib/neeto_commons_backend/initializers/neeto_mail_interceptor.rb