noticed 1.5.1 → 1.5.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
2
  SHA256:
3
- metadata.gz: ff995fcfa939d664a292e883fb4b6b40bb1510c75411bb18d9bee4787f3ccb3a
4
- data.tar.gz: c4945ef3d031a3c6565a56826e6538a1e11f4133dc4b8aba5c97e52279e69e0e
3
+ metadata.gz: 90b43c50384068092455c10cd6686fc46cd766121c0ea5cf593bbc4c8306e8de
4
+ data.tar.gz: 23edb385b0c9981dd9c292c8f4c15ce6fadd9abb131adc1eb6440ab39c5fa186
5
5
  SHA512:
6
- metadata.gz: 5f087a2e98dbe9c746b334721f5a1807e8cff6373cb2e342ce24abecbc1365f90f93a1282adfba37e8c72f432975354dbd68ff58bc099ec1a02579cce6394caf
7
- data.tar.gz: d4ae42066070141132d248d9c76dcbb4b84c19b3c19a2c652e0bdcefb59517719ccbba0a120bd439a4b89f0f6425dc8df0a5f5f5cf9ed633ea8cb32b6e2f9975
6
+ metadata.gz: 9a5d92df6618d53f8be91ca71bdf6dfc6ff0b66279662a5690c6efaa162939f2ae4fe1868956427ff10a83fa77329c16c96af3faef9e2fa48e441f1478c91ed0
7
+ data.tar.gz: 6d485a661fe14b24811479615e125cb4bf2794808dd28b39c102e677b1a1e99a0f22807acbc75a728442764f521c498ffa884998e243dacad5ea9e4e4cd2ca19
data/lib/noticed/base.rb CHANGED
@@ -81,6 +81,8 @@ module Noticed
81
81
  def run_delivery(recipient, enqueue: true)
82
82
  delivery_methods = self.class.delivery_methods.dup
83
83
 
84
+ self.recipient = recipient
85
+
84
86
  # Run database delivery inline first if it exists so other methods have access to the record
85
87
  if (index = delivery_methods.find_index { |m| m[:name] == :database })
86
88
  delivery_method = delivery_methods.delete_at(index)
@@ -9,7 +9,7 @@ module Noticed
9
9
  raise ArgumentError, "bundle_identifier is missing" if bundle_identifier.blank?
10
10
  raise ArgumentError, "key_id is missing" if key_id.blank?
11
11
  raise ArgumentError, "team_id is missing" if team_id.blank?
12
- raise ArgumentError, "Could not find APN cert at '#{cert_path}'" unless File.exist?(cert_path)
12
+ raise ArgumentError, "Could not find APN cert at '#{cert_path}'" unless valid_cert_path?
13
13
 
14
14
  device_tokens.each do |device_token|
15
15
  connection_pool.with do |connection|
@@ -78,7 +78,7 @@ module Noticed
78
78
  end
79
79
  end
80
80
 
81
- if options[:development]
81
+ if development?
82
82
  Apnotic::ConnectionPool.development(connection_pool_options, pool_options, &handler)
83
83
  else
84
84
  Apnotic::ConnectionPool.new(connection_pool_options, pool_options, &handler)
@@ -142,6 +142,25 @@ module Noticed
142
142
  end
143
143
  end
144
144
 
145
+ def development?
146
+ option = options[:development]
147
+ case option
148
+ when Symbol
149
+ !!notification.send(option)
150
+ else
151
+ !!option
152
+ end
153
+ end
154
+
155
+ def valid_cert_path?
156
+ case cert_path
157
+ when File, StringIO
158
+ cert_path.size > 0
159
+ else
160
+ File.exist?(cert_path)
161
+ end
162
+ end
163
+
145
164
  def pool_options
146
165
  {
147
166
  size: options.fetch(:pool_size, 5)
data/lib/noticed/model.rb CHANGED
@@ -1,5 +1,13 @@
1
1
  module Noticed
2
2
  module Model
3
+ DATABASE_ERROR_CLASS_NAMES = lambda {
4
+ classes = [ActiveRecord::NoDatabaseError]
5
+ classes << ActiveRecord::ConnectionNotEstablished
6
+ classes << Mysql2::Error if defined?(::Mysql2)
7
+ classes << PG::ConnectionBad if defined?(::PG)
8
+ classes
9
+ }.call.freeze
10
+
3
11
  extend ActiveSupport::Concern
4
12
 
5
13
  included do
@@ -32,7 +40,9 @@ module Noticed
32
40
  else
33
41
  Noticed::TextCoder
34
42
  end
35
- rescue ActiveRecord::NoDatabaseError
43
+ rescue *DATABASE_ERROR_CLASS_NAMES => _error
44
+ warn("Noticed was unable to bootstrap correctly as the database is unavailable.")
45
+
36
46
  Noticed::TextCoder
37
47
  end
38
48
  end
@@ -1,3 +1,3 @@
1
1
  module Noticed
2
- VERSION = "1.5.1"
2
+ VERSION = "1.5.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: noticed
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Oliver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-15 00:00:00.000000000 Z
11
+ date: 2021-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails