postageapp 1.4.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3294326a99a50b10d39f0b68af1e25dc18dd6cb929046dd30f7ebcd6367f8987
4
- data.tar.gz: d6a628106475cec85f377e237413b7e22d88964dd2054479042be04c8d0ce029
3
+ metadata.gz: 8fb7fce16defbeb345e4b38780b1fe03a30b15aa60a6da835366f7ae583fef0e
4
+ data.tar.gz: 5201a95c68b7c63ae1db1059131dd31fbc0a4945ebec7f8540ac52d838a81f6a
5
5
  SHA512:
6
- metadata.gz: ee2a734533ec2c23a25d8197e315231ff23d6441fe966b283b8689b8571ae70578df1c53d1345ced6c5d1ef8eebc66b09a5acee5f721c1a1ce424ef7c6478c9f
7
- data.tar.gz: 8c37fe050d9339d40c9949bb338a65a962b11de45d835d979ef1a09957de932e520eef7e45e4b77fc864d2bb8df5ab4f6fb0cc9039ddb5413299d7dadabb0ac3
6
+ metadata.gz: d57a61ffdc8390963c98490e6b0e68cf98ccf396294cd603acc35c1874044d4453d69ccdbccb550f2cbc7746d64b19078dd62be7d915d80527922048c9909d97
7
+ data.tar.gz: d93cbdac054b4b5cce7c18e64aa911970c8746293b87f595e1964ccfccc63ad4f7ef9df09412a6e167b9c8982645dd679b56ef90a31f1cb19deda2cc967ef04d
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.1
1
+ 1.4.2
@@ -1,50 +1,52 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class ActionMailbox::Ingresses::PostageApp::InboundEmailsController < ActionMailbox::BaseController
4
- before_action :hmac_authenticate
3
+ if (defined?(ActionMailbox) and defined?(ActionMailbox::BaseController))
4
+ class ActionMailbox::Ingresses::PostageApp::InboundEmailsController < ActionMailbox::BaseController
5
+ before_action :hmac_authenticate
5
6
 
6
- def create
7
- ActionMailbox::InboundEmail.create_and_extract_message_id!(message_param)
7
+ def create
8
+ ActionMailbox::InboundEmail.create_and_extract_message_id!(message_param)
8
9
 
9
- head(:ok)
10
+ head(:ok)
10
11
 
11
- rescue JSON::ParserError => e
12
- logger.error(e.message)
12
+ rescue JSON::ParserError => e
13
+ logger.error(e.message)
13
14
 
14
- head(:unprocessable_entity)
15
- end
15
+ head(:unprocessable_entity)
16
+ end
16
17
 
17
- private
18
- def message_param
19
- params.require(:inbound_email).require(:message)
20
- end
18
+ private
19
+ def message_param
20
+ params.require(:inbound_email).require(:message)
21
+ end
21
22
 
22
- def hmac_authenticate
23
- return if (hmac_authenticated?)
23
+ def hmac_authenticate
24
+ return if (hmac_authenticated?)
24
25
 
25
- head(:unauthorized)
26
- end
26
+ head(:unauthorized)
27
+ end
27
28
 
28
- def hmac_authenticated?
29
- if (PostageApp.config.postback_secret.present?)
30
- ActiveSupport::SecurityUtils.secure_compare(
31
- request.headers["X-PostageApp-Signature"],
32
- hmac_signature(message_param, PostageApp.config.postback_secret)
33
- )
34
- else
35
- raise ArgumentError, <<~END.squish
36
- Missing required PostageApp "postback secret" which can be set as
37
- in the Rails Encypted Credentials, as POSTAGEAPP_API_POSTBACK_SECRET
38
- in the environment, or via a config/initializer script using the
39
- PostageApp.config method.
40
- END
29
+ def hmac_authenticated?
30
+ if (PostageApp.config.postback_secret.present?)
31
+ ActiveSupport::SecurityUtils.secure_compare(
32
+ request.headers["X-PostageApp-Signature"],
33
+ hmac_signature(message_param, PostageApp.config.postback_secret)
34
+ )
35
+ else
36
+ raise ArgumentError, <<~END.squish
37
+ Missing required PostageApp "postback secret" which can be set as
38
+ in the Rails Encypted Credentials, as POSTAGEAPP_API_POSTBACK_SECRET
39
+ in the environment, or via a config/initializer script using the
40
+ PostageApp.config method.
41
+ END
42
+ end
41
43
  end
42
- end
43
44
 
44
- private
45
- def hmac_signature(*content)
46
- Base64.strict_encode64(
47
- OpenSSL::HMAC.digest(OpenSSL::Digest::SHA1.new, *content)
48
- )
45
+ private
46
+ def hmac_signature(*content)
47
+ Base64.strict_encode64(
48
+ OpenSSL::HMAC.digest(OpenSSL::Digest::SHA1.new, *content)
49
+ )
50
+ end
49
51
  end
50
52
  end
@@ -1,2 +1,4 @@
1
- module ActionMailbox::Ingresses::PostageApp
1
+ if (defined?(ActionMailbox))
2
+ module ActionMailbox::Ingresses::PostageApp
3
+ end
2
4
  end
data/config/routes.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  PostageApp::Engine.routes.draw do
2
- scope "/rails/action_mailbox", module: "action_mailbox/ingresses" do
3
- post "/postageapp/inbound_emails" => "postage_app/inbound_emails#create",
4
- as: :rails_postageapp_inbound_emails
2
+ if (defined?(ActionMailbox))
3
+ scope '/rails/action_mailbox', module: 'action_mailbox/ingresses' do
4
+ post '/postageapp/inbound_emails' => 'postage_app/inbound_emails#create',
5
+ as: :rails_postageapp_inbound_emails
6
+ end
5
7
  end
6
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postageapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Tadman
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-08-20 00:00:00.000000000 Z
13
+ date: 2021-08-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: mail