ses_blacklist_rails 0.0.4 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 85bb9f8c98b9ec2ef3b63666a702d7e410065c0b
4
- data.tar.gz: 3f83ebe69078712951ecdbe51ff950b5bd749941
3
+ metadata.gz: ee9576ef3f25682c6b2cb90f67a155c860863284
4
+ data.tar.gz: 3bf58fb824e3ad9d6b1f003a11e6666b8166768a
5
5
  SHA512:
6
- metadata.gz: 027bc8265595a73dde19b63c99048e6b93d262955a8facdd872f49b07510508876c5de9bdfc16af7517dba54850d111d9453b5cd1ac8ae90bdef4e58af502126
7
- data.tar.gz: 162c3e3bde7bb610812bd2fbbad7ba4210a2782370c0d2f46364effe045b56745d99355e879bd641076e2bc14cebd62f798f438c49bff6318118aaa5b5866f66
6
+ metadata.gz: a8b175376266110ac9b4616a8f030f2bdb77b85a52a382c9f2d3ec02f055ea24d4cc805a46e7a4a74c1671b1ed78410df176307f7bdbe548eb5785daad5af3c1
7
+ data.tar.gz: de49fe1fe1fcd8dc986e95a08b7b1ed34832137d8484b89322957704e5ef8453b8baa7947fe0f7d511a1a307a5d39f0d91311965506fb1238b3c16b2a1116885
@@ -7,18 +7,30 @@ module SesBlacklistRails
7
7
  before_action :parse_request
8
8
 
9
9
  def index
10
- case @params[:notificationType]
11
- when 'Bounce'
12
- @params[:bounce][:bouncedRecipients].each do |r|
13
- create_notification(r, :bounce)
10
+ if @params[:Type] == 'SubscriptionConfirmation'
11
+ create_notification('', :other)
12
+ begin
13
+ uri = URI.parse @params[:SubscribeURL]
14
+ res = Net::HTTP.get_response uri
15
+ return render plain: '', status: 500 if res.code.to_i != 200
16
+ rescue StandardError
17
+ return render plain: '', status: 500
14
18
  end
15
- when 'Complaint'
16
- @params[:complaint][:complainedRecipients].each do |r|
17
- create_notification(r, :complaint)
18
- end
19
- when 'Delivery'
20
- @params[:delivery][:recipients].each do |r|
21
- create_notification(r, :delivery)
19
+
20
+ else
21
+ case @params[:notificationType]
22
+ when 'Bounce'
23
+ @params[:bounce][:bouncedRecipients].each do |r|
24
+ create_notification(r, :bounce)
25
+ end
26
+ when 'Complaint'
27
+ @params[:complaint][:complainedRecipients].each do |r|
28
+ create_notification(r, :complaint)
29
+ end
30
+ when 'Delivery'
31
+ @params[:delivery][:recipients].each do |r|
32
+ create_notification(r, :delivery)
33
+ end
22
34
  end
23
35
  end
24
36
  end
@@ -32,7 +44,7 @@ module SesBlacklistRails
32
44
  def create_notification(recipient, type)
33
45
  Notification.create(
34
46
  notification_type: Notification.notification_types[type],
35
- email: type == :delivery ? recipient : recipient[:emailAddress],
47
+ email: %i[delivery other].include?(type) ? recipient : recipient[:emailAddress],
36
48
  log: @params
37
49
  )
38
50
  end
@@ -5,7 +5,8 @@ module SesBlacklistRails
5
5
  enum notification_type: {
6
6
  bounce: 0,
7
7
  complaint: 1,
8
- delivery: 2
8
+ delivery: 2,
9
+ other: 9
9
10
  }
10
11
  end
11
12
  end
@@ -1,3 +1,3 @@
1
1
  module SesBlacklistRails
2
- VERSION = '0.0.4'.freeze
2
+ VERSION = '0.1.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ses_blacklist_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mrdShinse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-24 00:00:00.000000000 Z
11
+ date: 2017-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails