ses_blacklist_rails 0.1.3 → 0.1.5

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
- SHA1:
3
- metadata.gz: '09601f9eab1ead0944d98bc02ee11dea6da748bf'
4
- data.tar.gz: 517f916e0fb9db37869962bb4fcd884fcac8661a
2
+ SHA256:
3
+ metadata.gz: edb8ab1818899ae5e658327dc9be87f5bbaa4f15352ad5f13bbf9434664be564
4
+ data.tar.gz: a772e98108ee7a1f51c504889c158c77da6b87f733188e06c2908866b732ad51
5
5
  SHA512:
6
- metadata.gz: 64cf46c009bf30d8c5b74ee0ebea4dd76c0d6a0d92eb869c81c0a83e98b85408d2c77768b1fc63aa095d21360a7c7d4b99fefa5032f4bcb6b8bfd263e341d60d
7
- data.tar.gz: 29a2f7391433c47d482020c67404d8258adab93f305cdc89ce9129e451ad79f4db009ace69fd6ef3dcfe6a7c90817a513ffb9950f0eda0f450ca54d8c82b9d83
6
+ metadata.gz: 8a23f0d10a8820dee53455928f25ba41ba07fb9a950efee9c2bc3a92a87fa0704ad3f2f71e69f93a04558e1a4979b80a31fdf7a3c07d37bd7f8d18c38cde3928
7
+ data.tar.gz: 8e4f09724df8d274bee1d9633fab5eda0caee77049805c4db0f96c7604dbb496b02a3df705db8fec532571bc51d1384f52e56b42f6aabeba0eae141e11102f63
data/README.md CHANGED
@@ -23,7 +23,7 @@ $ bundle exec rails g ses_blacklist_rails:install
23
23
  ```ruby
24
24
  SesBlacklistRails.configure do |config|
25
25
  config.send_bounce = false
26
- config.send_compliant = false
26
+ config.send_complaint = false
27
27
  config.default_address = 'some_address@sample.com'
28
28
  end
29
29
  ```
@@ -8,5 +8,15 @@ module SesBlacklistRails
8
8
  delivery: 2,
9
9
  other: 9
10
10
  }
11
+
12
+ class << self
13
+ def validate_bounce
14
+ @validate_bounce ||= ->(email) { self.bounce.where(email: email).any? }
15
+ end
16
+
17
+ def validate_complaint
18
+ @validate_complaint ||= ->(email) { self.complaint.where(email: email).any? }
19
+ end
20
+ end
11
21
  end
12
22
  end
@@ -1,5 +1,5 @@
1
1
  SesBlacklistRails.configure do |config|
2
2
  config.send_bounce = false
3
- config.send_compliant = false
3
+ config.send_complaint = false
4
4
  config.default_address = 'some_address@sample.com'
5
5
  end
@@ -1,12 +1,19 @@
1
+ require 'ses_blacklist_rails/action_mail_interceptor'
1
2
  require 'ses_blacklist_rails/config'
2
3
  require 'ses_blacklist_rails/engine'
3
4
 
4
5
  module SesBlacklistRails # :nodoc:
5
- def self.configure(*)
6
- yield config
7
- end
6
+ class << self
7
+ def configure(*)
8
+ yield config
9
+ end
10
+
11
+ def config
12
+ @config ||= SesBlacklistRails::Config.new
13
+ end
8
14
 
9
- def self.config
10
- @config ||= SesBlacklistRails::Config.new
15
+ delegate :send_bounce, to: :config
16
+ delegate :send_complaint, to: :config
17
+ delegate :default_address, to: :config
11
18
  end
12
19
  end
@@ -8,32 +8,33 @@ module SesBlacklistRails
8
8
  private
9
9
 
10
10
  def validate!(message)
11
- unless SesBlacklistRails.send_bounce
12
- validate_bounce = ->(email) { SesBlacklistRails::Notification.bounce.find_by(email: email) }
13
- message.to.reject!(validate_bounce)
14
- message.cc.reject!(validate_bounce)
15
- message.bcc.reject!(validate_bounce)
16
- end
17
-
18
- unless SesBlacklistRails.send_compliant
19
- validate_compliant = ->(email) { SesBlacklistRails::Notification.compliant.find_by(email: email) }
20
- message.to.reject!(validate_compliant)
21
- message.cc.reject!(validate_compliant)
22
- message.bcc.reject!(validate_compliant)
23
- end
11
+ sanitize_destination!(
12
+ message,
13
+ SesBlacklistRails::Notification.validate_bounce
14
+ ) unless SesBlacklistRails.send_bounce
15
+ sanitize_destination!(
16
+ message,
17
+ SesBlacklistRails::Notification.validate_complaint
18
+ ) unless SesBlacklistRails.send_complaint
24
19
 
25
20
  defualt_address!(message) if message.to.blank?
26
21
  message
27
22
  end
28
23
 
29
24
  def defualt_address!(message)
30
- if SesBlacklistRails::Notification.default_address.blank?
25
+ if SesBlacklistRails.default_address.blank?
31
26
  message.perform_deliveries = false
32
27
  else
33
- message.to << SesBlacklistRails::Notification.default_address
28
+ message.to = [SesBlacklistRails.default_address]
34
29
  end
35
30
  message
36
31
  end
32
+
33
+ def sanitize_destination!(message, validation)
34
+ message.to = message.to&.reject! &validation
35
+ message.cc = message.cc&.reject! &validation
36
+ message.bcc = message.bcc&.reject! &validation
37
+ end
37
38
  end
38
39
  end
39
40
  end
@@ -6,7 +6,7 @@ module SesBlacklistRails
6
6
  false
7
7
  end
8
8
 
9
- config_accessor :send_compliant do
9
+ config_accessor :send_complaint do
10
10
  false
11
11
  end
12
12
 
@@ -1,3 +1,3 @@
1
1
  module SesBlacklistRails
2
- VERSION = '0.1.3'.freeze
2
+ VERSION = '0.1.5'.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.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - mrdShinse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-21 00:00:00.000000000 Z
11
+ date: 2018-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
101
  version: '0'
102
102
  requirements: []
103
103
  rubyforge_project:
104
- rubygems_version: 2.6.11
104
+ rubygems_version: 2.7.6
105
105
  signing_key:
106
106
  specification_version: 4
107
107
  summary: AWS SES blacklist for Rails applications.