aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/action_mailbox/ingresses/mailgun/inbound_emails_controller.rb
diff options
context:
space:
mode:
authorGeorge Claghorn <george@basecamp.com>2018-10-29 13:45:24 -0400
committerGeorge Claghorn <george@basecamp.com>2018-10-29 13:45:24 -0400
commitbe0a8bec8701c7df2667dbf1569429218ea30370 (patch)
tree9dbf39394a938caa14411febca02db043d379b92 /app/controllers/action_mailbox/ingresses/mailgun/inbound_emails_controller.rb
parent02fcfec0c682cb3ff175927155a37e934ee1d0fe (diff)
downloadrails-be0a8bec8701c7df2667dbf1569429218ea30370.tar.gz
rails-be0a8bec8701c7df2667dbf1569429218ea30370.tar.bz2
rails-be0a8bec8701c7df2667dbf1569429218ea30370.zip
Raise when required config is missing
Diffstat (limited to 'app/controllers/action_mailbox/ingresses/mailgun/inbound_emails_controller.rb')
-rw-r--r--app/controllers/action_mailbox/ingresses/mailgun/inbound_emails_controller.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/app/controllers/action_mailbox/ingresses/mailgun/inbound_emails_controller.rb b/app/controllers/action_mailbox/ingresses/mailgun/inbound_emails_controller.rb
index 46b0977592..c7e53b07f4 100644
--- a/app/controllers/action_mailbox/ingresses/mailgun/inbound_emails_controller.rb
+++ b/app/controllers/action_mailbox/ingresses/mailgun/inbound_emails_controller.rb
@@ -24,6 +24,8 @@ class ActionMailbox::Ingresses::Mailgun::InboundEmailsController < ActionMailbox
def initialize(timestamp:, token:, signature:)
@timestamp, @token, @signature = Integer(timestamp), token, signature
+
+ ensure_presence_of_key
end
def authenticated?
@@ -31,6 +33,13 @@ class ActionMailbox::Ingresses::Mailgun::InboundEmailsController < ActionMailbox
end
private
+ def ensure_presence_of_key
+ unless key.present?
+ raise ArgumentError, "Missing required Mailgun API key"
+ end
+ end
+
+
def signed?
ActiveSupport::SecurityUtils.secure_compare signature, expected_signature
end