Sha256: 646f2244a1fb254f0c6676225e4fc481b649aeb0f01f0bcefef13da8926f93d4

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

#
# AWS SES SSO Configuration
#
module SesConfiguration
  extend ActiveSupport::Concern

  def self.included(base)
    base.class_eval do
      #
      # Fields
      #
      field :ses_source, type: String
      field :ses_source_arn_prefix, type: String
      field :ses_bounce_queue_name, type: String
      field :ses_region, type: String
    end
  end

  #
  # Determine if AWS is configured
  #
  def ses_configured?
    aws_configured? &&
      ses_source.present? &&
      ses_source_arn_prefix.present? &&
      (ses_region.present? || aws_region.present?)
  end

  def ses_source_arn(source = ses_source)
    [ses_source_arn_prefix, source].compact.join('/')
  end

  #
  # SES Client
  #
  def aws_ses_client
    return nil unless ses_configured?

    # We want this to remake itself each time because it is possible that the
    # => user would change the access keys in between actions. Huh?
    @aws_ses_client ||= Aws::SES::Client.new(region: ses_region.presence || aws_region, credentials: aws_credentials)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
web47core-2.3.0 lib/app/models/concerns/ses_configuration.rb