diff options
author | George Claghorn <george@basecamp.com> | 2018-11-05 12:39:37 -0500 |
---|---|---|
committer | George Claghorn <george@basecamp.com> | 2018-11-05 12:39:37 -0500 |
commit | b859eebff8545eea972d479137e14b917e6519dc (patch) | |
tree | 1473c5e5a67703e73633956a061735127c05e720 /app/controllers/action_mailbox | |
parent | d02ae4c7ae336412a5ff19400cda6b87ed58a465 (diff) | |
download | rails-b859eebff8545eea972d479137e14b917e6519dc.tar.gz rails-b859eebff8545eea972d479137e14b917e6519dc.tar.bz2 rails-b859eebff8545eea972d479137e14b917e6519dc.zip |
Only load the AWS SDK when the Amazon ingress is configured
Diffstat (limited to 'app/controllers/action_mailbox')
-rw-r--r-- | app/controllers/action_mailbox/base_controller.rb | 4 | ||||
-rw-r--r-- | app/controllers/action_mailbox/ingresses/amazon/inbound_emails_controller.rb | 11 |
2 files changed, 12 insertions, 3 deletions
diff --git a/app/controllers/action_mailbox/base_controller.rb b/app/controllers/action_mailbox/base_controller.rb index a2f7eb4b61..c234ecd250 100644 --- a/app/controllers/action_mailbox/base_controller.rb +++ b/app/controllers/action_mailbox/base_controller.rb @@ -1,6 +1,10 @@ class ActionMailbox::BaseController < ActionController::Base skip_forgery_protection + def self.prepare + # Override in concrete controllers to run code on load. + end + before_action :ensure_configured private diff --git a/app/controllers/action_mailbox/ingresses/amazon/inbound_emails_controller.rb b/app/controllers/action_mailbox/ingresses/amazon/inbound_emails_controller.rb index 4d56e27c76..d3998be2d4 100644 --- a/app/controllers/action_mailbox/ingresses/amazon/inbound_emails_controller.rb +++ b/app/controllers/action_mailbox/ingresses/amazon/inbound_emails_controller.rb @@ -1,9 +1,14 @@ class ActionMailbox::Ingresses::Amazon::InboundEmailsController < ActionMailbox::BaseController before_action :authenticate - # TODO: Lazy-load the AWS SDK - require "aws-sdk-sns/message_verifier" - cattr_accessor :verifier, default: Aws::SNS::MessageVerifier.new + cattr_accessor :verifier + + def self.prepare + self.verifier ||= begin + require "aws-sdk-sns/message_verifier" + Aws::SNS::MessageVerifier.new + end + end def create ActionMailbox::InboundEmail.create_and_extract_message_id! params.require(:content) |