rpush 3.2.3 → 3.2.4

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: 62fa8d44a553579e32d0859ed2467d3936f6df0e
4
- data.tar.gz: 8d33b51e1793599eca5cc4c0f827c471325e6a12
2
+ SHA256:
3
+ metadata.gz: 034d8de0f4696f840692ef88e5646af49cd424603ef0417be06312a58a61a640
4
+ data.tar.gz: 3bcadf28d715b047c1f1b0f6b60326b58d365eded8ddaf1e1d78c5b5f81c39a8
5
5
  SHA512:
6
- metadata.gz: 691dac9abba2c447b4246aee2bdac9e06eb43d7d233755c6867580c35043cef48854c010eeb30d25630ddae4caa1368983e173ac6db84bc6f1e1356eae05b820
7
- data.tar.gz: 9b19217c52856b769fb5d326b9468cdfdc7faea297433fea4c4d499e1578b21eb4df01c88e9afe0c6fd7cc7db53057444e5ec6fff0b063ee5ea1bdfad5bc015f
6
+ metadata.gz: 937b1b6b68cc949bf6b28f10ca4c3ca78ec0811a87f4ff3bd926a6318d26042bea787ab067cb4c04801b35c7183180dafc474e1df22d64636035f8c0d7e8d047
7
+ data.tar.gz: 971f4544764419a4a08b8cdea97d58126d759deb145cc76567c4465bbf4db1154ef6bc46da04c729cc5bd3cedf709c71b93ee6269311179f32c4034780ab2f5a
@@ -12,6 +12,23 @@
12
12
 
13
13
  - None
14
14
 
15
+ ## 3.2.4 (2018-10-25)
16
+
17
+ When upgrading, don't forget to run `bundle exec rpush init` to get all the latest migrations.
18
+
19
+ ### Changes
20
+
21
+ - Relaxed JWT dependency version [#447](https://github.com/rpush/rpush/pull/447) (by [@sposin](https://github.com/sposin)).
22
+
23
+ ### Docs
24
+
25
+ - Better documentation for running tests when developing Rpush [#458](https://github.com/rpush/rpush/pull/458) (by [@jsantos](https://github.com/jsantos)).
26
+
27
+ ### Fixed
28
+
29
+ - Change `apn_key` column type from string to text [#455](https://github.com/rpush/rpush/pull/455) (by [sonxurxo](https://github.com/sonxurxo)).
30
+ - Retry all GCM 5xx errors [#456](https://github.com/rpush/rpush/pull/456) (by [@rofreg](https://github.com/rofreg)).
31
+
15
32
  ## 3.2.3 (2018-07-12)
16
33
 
17
34
  ### Changes
data/README.md CHANGED
@@ -347,6 +347,41 @@ You should run `rpush init` after upgrading Rpush to check for configuration and
347
347
 
348
348
  ### Contributing
349
349
 
350
+ #### Running Tests
351
+
352
+ Rpush uses [Appraisal](https://github.com/thoughtbot/appraisal) to run tests against multiple versions of Ruby on Rails. This helps making sure that Rpush performs correctly with multiple Rails versions.
353
+
354
+ Rpush also uses RSpec for its tests.
355
+
356
+ ##### Bootstrapping your test suite:
357
+
358
+ First, we need to setup a test database, `rpush_test`.
359
+
360
+ E.g. (postgres): `psql -c 'create database rpush_test;' -U postgres >/dev/null`
361
+
362
+ ```
363
+ bundle install
364
+ bundle exec appraisal install
365
+ ```
366
+ This will install all the required gems that requires to test against each version of Rails, which defined in `gemfiles/*.gemfile`.
367
+
368
+ ##### To run a full test suite:
369
+
370
+ ```
371
+ bundle exec appraisal rake
372
+ ```
373
+ This will run RSpec against all versions of Rails.
374
+
375
+ ##### To run a single test
376
+
377
+ You need to specify a `BUNDLE_GEMFILE` pointing to the gemfile before running the normal test command:
378
+
379
+ ```
380
+ BUNDLE_GEMFILE=gemfiles/rails_5.2.gemfile rspec spec/unit/apns_feedback_spec.rb
381
+ ```
382
+
383
+ ##### Multiple database adapter support
384
+
350
385
  When running specs, please note that the ActiveRecord adapter can be changed by setting the `ADAPTER` environment variable. For example: `ADAPTER=postgresql rake`.
351
386
 
352
387
  Available adapters for testing are `postgresql`, `jdbcpostgresql`, `mysql2`, `jdbcmysql`, `jdbch2`, and `sqlite3`.
@@ -47,6 +47,7 @@ class RpushMigrationGenerator < Rails::Generators::Base
47
47
  add_rpush_migration('rpush_3_1_0_add_pushy')
48
48
  add_rpush_migration('rpush_3_1_1_updates')
49
49
  add_rpush_migration('rpush_3_2_0_add_apns_p8')
50
+ add_rpush_migration('rpush_3_2_4_updates')
50
51
  end
51
52
 
52
53
  protected
@@ -0,0 +1,9 @@
1
+ class Rpush324Updates < ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Migration[5.0] : ActiveRecord::Migration
2
+ def self.up
3
+ change_column :rpush_apps, :apn_key, :text, null: true
4
+ end
5
+
6
+ def self.down
7
+ change_column :rpush_apps, :apn_key, :string, null: true
8
+ end
9
+ end
@@ -7,7 +7,7 @@ module Rpush
7
7
 
8
8
  host = 'https://fcm.googleapis.com'
9
9
  FCM_URI = URI.parse("#{host}/fcm/send")
10
- UNAVAILABLE_STATES = %w(Unavailable InternalServerError)
10
+ UNAVAILABLE_STATES = %w(Unavailable BadGateway InternalServerError)
11
11
  INVALID_REGISTRATION_ID_STATES = %w(InvalidRegistration MismatchSenderId NotRegistered InvalidPackageName)
12
12
 
13
13
  def initialize(app, http, notification, batch)
@@ -41,8 +41,12 @@ module Rpush
41
41
  unauthorized
42
42
  when 500
43
43
  internal_server_error(response)
44
+ when 502
45
+ bad_gateway(response)
44
46
  when 503
45
47
  service_unavailable(response)
48
+ when 500..599
49
+ other_5xx_error(response)
46
50
  else
47
51
  fail Rpush::DeliveryError.new(response.code.to_i, @notification.id, Rpush::Daemon::HTTP_STATUS_CODES[response.code.to_i])
48
52
  end
@@ -119,11 +123,21 @@ module Rpush
119
123
  log_warn("GCM responded with an Internal Error. " + retry_message)
120
124
  end
121
125
 
126
+ def bad_gateway(response)
127
+ retry_delivery(@notification, response)
128
+ log_warn("GCM responded with a Bad Gateway Error. " + retry_message)
129
+ end
130
+
122
131
  def service_unavailable(response)
123
132
  retry_delivery(@notification, response)
124
133
  log_warn("GCM responded with an Service Unavailable Error. " + retry_message)
125
134
  end
126
135
 
136
+ def other_5xx_error(response)
137
+ retry_delivery(@notification, response)
138
+ log_warn("GCM responded with a 5xx Error. " + retry_message)
139
+ end
140
+
127
141
  def deliver_after_header(response)
128
142
  Rpush::Daemon::RetryHeaderParser.parse(response.header['retry-after'])
129
143
  end
@@ -2,7 +2,7 @@ module Rpush
2
2
  module VERSION
3
3
  MAJOR = 3
4
4
  MINOR = 2
5
- TINY = 3
5
+ TINY = 4
6
6
  PRE = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".").freeze
@@ -36,6 +36,7 @@ require 'generators/templates/rpush_3_0_1_updates'
36
36
  require 'generators/templates/rpush_3_1_0_add_pushy'
37
37
  require 'generators/templates/rpush_3_1_1_updates'
38
38
  require 'generators/templates/rpush_3_2_0_add_apns_p8'
39
+ require 'generators/templates/rpush_3_2_4_updates'
39
40
 
40
41
  migrations = [
41
42
  AddRpush,
@@ -47,7 +48,8 @@ migrations = [
47
48
  Rpush301Updates,
48
49
  Rpush310AddPushy,
49
50
  Rpush311Updates,
50
- Rpush320AddApnsP8
51
+ Rpush320AddApnsP8,
52
+ Rpush324Updates
51
53
  ]
52
54
 
53
55
  unless ENV['TRAVIS']
@@ -282,6 +282,34 @@ describe Rpush::Daemon::Gcm::Delivery do
282
282
  end
283
283
  end
284
284
 
285
+ describe 'a 502 response' do
286
+ before { allow(response).to receive_messages(code: 502) }
287
+
288
+ it 'logs a warning that the notification will be retried.' do
289
+ notification.retries = 1
290
+ notification.deliver_after = now + 2
291
+ expect(logger).to receive(:warn).with("[MyApp] GCM responded with a Bad Gateway Error. Notification #{notification.id} will be retried after 2012-10-14 00:00:02 (retry 1).")
292
+ perform
293
+ end
294
+
295
+ it 'respects an integer Retry-After header' do
296
+ allow(response).to receive_messages(header: { 'retry-after' => 10 })
297
+ expect(delivery).to receive(:mark_retryable).with(notification, now + 10.seconds)
298
+ perform
299
+ end
300
+
301
+ it 'respects a HTTP-date Retry-After header' do
302
+ allow(response).to receive_messages(header: { 'retry-after' => 'Wed, 03 Oct 2012 20:55:11 GMT' })
303
+ expect(delivery).to receive(:mark_retryable).with(notification, Time.parse('Wed, 03 Oct 2012 20:55:11 GMT'))
304
+ perform
305
+ end
306
+
307
+ it 'defaults to exponential back-off if the Retry-After header is not present' do
308
+ expect(delivery).to receive(:mark_retryable).with(notification, now + 2**1)
309
+ perform
310
+ end
311
+ end
312
+
285
313
  describe 'a 500 response' do
286
314
  before do
287
315
  notification.update_attribute(:retries, 2)
@@ -301,6 +329,34 @@ describe Rpush::Daemon::Gcm::Delivery do
301
329
  end
302
330
  end
303
331
 
332
+ describe 'a 5xx response' do
333
+ before { allow(response).to receive_messages(code: 555) }
334
+
335
+ it 'logs a warning that the notification will be retried.' do
336
+ notification.retries = 1
337
+ notification.deliver_after = now + 2
338
+ expect(logger).to receive(:warn).with("[MyApp] GCM responded with a 5xx Error. Notification #{notification.id} will be retried after 2012-10-14 00:00:02 (retry 1).")
339
+ perform
340
+ end
341
+
342
+ it 'respects an integer Retry-After header' do
343
+ allow(response).to receive_messages(header: { 'retry-after' => 10 })
344
+ expect(delivery).to receive(:mark_retryable).with(notification, now + 10.seconds)
345
+ perform
346
+ end
347
+
348
+ it 'respects a HTTP-date Retry-After header' do
349
+ allow(response).to receive_messages(header: { 'retry-after' => 'Wed, 03 Oct 2012 20:55:11 GMT' })
350
+ expect(delivery).to receive(:mark_retryable).with(notification, Time.parse('Wed, 03 Oct 2012 20:55:11 GMT'))
351
+ perform
352
+ end
353
+
354
+ it 'defaults to exponential back-off if the Retry-After header is not present' do
355
+ expect(delivery).to receive(:mark_retryable).with(notification, now + 2**1)
356
+ perform
357
+ end
358
+ end
359
+
304
360
  describe 'a 401 response' do
305
361
  before { allow(response).to receive_messages(code: 401) }
306
362
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rpush
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.3
4
+ version: 3.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Leitch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-12 00:00:00.000000000 Z
11
+ date: 2018-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: jwt
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 2.1.0
61
+ version: 1.5.6
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: 2.1.0
68
+ version: 1.5.6
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: activesupport
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -387,6 +387,7 @@ files:
387
387
  - lib/generators/templates/rpush_3_1_0_add_pushy.rb
388
388
  - lib/generators/templates/rpush_3_1_1_updates.rb
389
389
  - lib/generators/templates/rpush_3_2_0_add_apns_p8.rb
390
+ - lib/generators/templates/rpush_3_2_4_updates.rb
390
391
  - lib/rpush.rb
391
392
  - lib/rpush/apns_feedback.rb
392
393
  - lib/rpush/cli.rb
@@ -623,7 +624,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
623
624
  version: '0'
624
625
  requirements: []
625
626
  rubyforge_project:
626
- rubygems_version: 2.6.13
627
+ rubygems_version: 2.7.6
627
628
  signing_key:
628
629
  specification_version: 4
629
630
  summary: The push notification service for Ruby.