Skip to content

Commit

Permalink
Validate ActionMailer config (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
mullermp authored Jul 8, 2024
1 parent 281f6e6 commit b1bffe8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
Unreleased Changes
------------------

* Issue - Ensure `:ses` or `:sesv2` as ActionMailer configuration.

* Feature - Do not allow `:amazon`, `amazon_sqs`, or `amazon_sqs_async` for SQS active job configuration. Instead use `:sqs` and `:sqs_async`.


3.13.0 (2024-06-06)
------------------

Expand Down
16 changes: 10 additions & 6 deletions lib/aws/rails/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Railtie < ::Rails::Railtie
before: :load_config_initializers do
# Initialization Actions
Aws::Rails.use_rails_encrypted_credentials
Aws::Rails.add_action_mailer_delivery_method
Aws::Rails.add_action_mailer_delivery_method(:ses)
Aws::Rails.add_action_mailer_delivery_method(:sesv2)
Aws::Rails.log_to_rails_logger
end
Expand All @@ -25,18 +25,22 @@ class Railtie < ::Rails::Railtie
end

# This is called automatically from the SDK's Railtie, but can be manually
# called if you want to specify options for building the Aws::SES::Client.
# called if you want to specify options for building the Aws::SES::Client or
# Aws::SESV2::Client.
#
# @param [Symbol] name The name of the ActionMailer delivery method to
# register.
# register, either :ses or :sesv2.
# @param [Hash] client_options The options you wish to pass on to the
# Aws::SES[V2]::Client initialization method.
def self.add_action_mailer_delivery_method(name = :ses, client_options = {})
def self.add_action_mailer_delivery_method(name, client_options = {})
ActiveSupport.on_load(:action_mailer) do
if name == :sesv2
case name
when :ses
add_delivery_method(name, Aws::Rails::SesMailer, client_options)
when :sesv2
add_delivery_method(name, Aws::Rails::Sesv2Mailer, client_options)
else
add_delivery_method(name, Aws::Rails::SesMailer, client_options)
raise ArgumentError, "Unknown action mailer delivery method: #{name}"
end
end
end
Expand Down

0 comments on commit b1bffe8

Please sign in to comment.