rpush 5.4.0 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +25 -0
- data/README.md +2 -2
- data/lib/generators/templates/add_adm.rb +1 -1
- data/lib/generators/templates/add_alert_is_json_to_rapns_notifications.rb +2 -2
- data/lib/generators/templates/add_app_to_rapns.rb +2 -2
- data/lib/generators/templates/add_fail_after_to_rpush_notifications.rb +1 -1
- data/lib/generators/templates/add_gcm.rb +7 -21
- data/lib/generators/templates/add_rpush.rb +29 -79
- data/lib/generators/templates/add_wpns.rb +1 -1
- data/lib/generators/templates/create_rapns_apps.rb +1 -1
- data/lib/generators/templates/create_rapns_feedback.rb +3 -9
- data/lib/generators/templates/create_rapns_notifications.rb +3 -9
- data/lib/generators/templates/rename_rapns_to_rpush.rb +9 -33
- data/lib/generators/templates/rpush_2_0_0_updates.rb +5 -17
- data/lib/generators/templates/rpush_2_1_0_updates.rb +1 -1
- data/lib/generators/templates/rpush_2_6_0_updates.rb +1 -1
- data/lib/generators/templates/rpush_2_7_0_updates.rb +1 -1
- data/lib/generators/templates/rpush_3_0_0_updates.rb +1 -1
- data/lib/generators/templates/rpush_3_0_1_updates.rb +1 -1
- data/lib/generators/templates/rpush_3_1_0_add_pushy.rb +1 -1
- data/lib/generators/templates/rpush_3_1_1_updates.rb +1 -1
- data/lib/generators/templates/rpush_3_2_0_add_apns_p8.rb +1 -1
- data/lib/generators/templates/rpush_3_2_4_updates.rb +1 -1
- data/lib/generators/templates/rpush_3_3_0_updates.rb +1 -1
- data/lib/generators/templates/rpush_3_3_1_updates.rb +1 -1
- data/lib/generators/templates/rpush_4_1_0_updates.rb +1 -1
- data/lib/generators/templates/rpush_4_1_1_updates.rb +1 -1
- data/lib/generators/templates/rpush_4_2_0_updates.rb +1 -1
- data/lib/rpush/client/active_model.rb +1 -0
- data/lib/rpush/client/active_model/apns/app.rb +1 -17
- data/lib/rpush/client/active_model/apns/notification.rb +4 -0
- data/lib/rpush/client/active_model/apns2/app.rb +7 -1
- data/lib/rpush/client/active_model/certificate_private_key_validator.rb +19 -0
- data/lib/rpush/daemon/apns2/delivery.rb +1 -0
- data/lib/rpush/daemon/apnsp8/delivery.rb +7 -1
- data/lib/rpush/daemon/string_helpers.rb +1 -1
- data/lib/rpush/version.rb +2 -2
- data/spec/functional/apns2_spec.rb +4 -2
- data/spec/functional/retry_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/support/active_record_setup.rb +4 -3
- data/spec/support/config/database.yml +4 -4
- data/spec/support/simplecov_helper.rb +1 -1
- data/spec/unit/client/active_record/apns/notification_spec.rb +1 -1
- data/spec/unit/client/active_record/apns2/app_spec.rb +1 -0
- data/spec/unit/client/active_record/apns2/notification_spec.rb +1 -1
- data/spec/unit/client/redis/apns/notification_spec.rb +1 -1
- data/spec/unit/client/redis/apns2/notification_spec.rb +1 -1
- data/spec/unit/client/shared/apns/notification.rb +15 -0
- data/spec/unit/daemon/apnsp8/delivery_spec.rb +53 -0
- metadata +8 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f8cbb341eafccf585f3967e5b1ef434a422f9a14175466060a978d2d4adbe4e
|
4
|
+
data.tar.gz: c8f767c447855b04a7e2d9e980a9408bdbafe11f6e84f711c0893122f2202cec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e6997a5008122ca85fed5a5f4eab96e0c6e585aa8fc4ab305c394608c10fb6bfdec2b79077e3098e137e173e65b0e7804038b5230013a51446d980ed2d6bb95
|
7
|
+
data.tar.gz: 5e6b265e5e034bebe78a30cdd4f2af63a08933777a58d86d1f8c6a73a2f4783fad7cba6f4b2181a08a79def81879594544979642dae8c3326de407205c6c4852
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,30 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [Unreleased](https://github.com/rpush/rpush/tree/HEAD)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/rpush/rpush/compare/v5.4.0...HEAD)
|
6
|
+
|
7
|
+
## [v6.0.0](https://github.com/rpush/rpush/tree/v6.0.0) (2021-05-21)
|
8
|
+
|
9
|
+
[Full Changelog](https://github.com/rpush/rpush/compare/v5.4.0...v6.0.0)
|
10
|
+
|
11
|
+
This release contains **breaking changes**, such as removing support for Rails versions older than 5.2.
|
12
|
+
Please see the details in the PRs below.
|
13
|
+
|
14
|
+
**Merged pull requests:**
|
15
|
+
|
16
|
+
- Switch to GitHub Actions for CI [\#615](https://github.com/rpush/rpush/pull/615) ([aried3r](https://github.com/aried3r))
|
17
|
+
- Prepare 6.0.0 release [\#613](https://github.com/rpush/rpush/pull/613) ([aried3r](https://github.com/aried3r))
|
18
|
+
- Bump activesupport version to 5.2 or later [\#610](https://github.com/rpush/rpush/pull/610) ([biow0lf](https://github.com/biow0lf))
|
19
|
+
- Fixed infinite loop issue with Apnsp8 delivery [\#608](https://github.com/rpush/rpush/pull/608) ([diminish7](https://github.com/diminish7))
|
20
|
+
- Eliminate deprecation warning in Ruby 3.0 [\#602](https://github.com/rpush/rpush/pull/602) ([rofreg](https://github.com/rofreg))
|
21
|
+
- Make ActiveRecord validations work with Apns2 client [\#601](https://github.com/rpush/rpush/pull/601) ([favrik](https://github.com/favrik))
|
22
|
+
- Bump gemspec post\_install\_message [\#600](https://github.com/rpush/rpush/pull/600) ([fdoxyz](https://github.com/fdoxyz))
|
23
|
+
- Remove references and checks for unsupported versions of Rails [\#599](https://github.com/rpush/rpush/pull/599) ([ericsaupe](https://github.com/ericsaupe))
|
24
|
+
- Drop support for Rails 5.0 and 5.1 [\#597](https://github.com/rpush/rpush/pull/597) ([ericsaupe](https://github.com/ericsaupe))
|
25
|
+
- Fix silent APNS notifications for Apns2 and Apnsp8 [\#596](https://github.com/rpush/rpush/pull/596) ([shved270189](https://github.com/shved270189))
|
26
|
+
- Updates README to Apple's new EOL date for the APNs legacy binary protocol [\#595](https://github.com/rpush/rpush/pull/595) ([gregblake](https://github.com/gregblake))
|
27
|
+
|
3
28
|
## [v5.4.0](https://github.com/rpush/rpush/tree/v5.4.0) (2021-02-15)
|
4
29
|
|
5
30
|
[Full Changelog](https://github.com/rpush/rpush/compare/v5.3.0...v5.4.0)
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
[![Gem Version](https://badge.fury.io/rb/rpush.svg)](http://badge.fury.io/rb/rpush)
|
2
|
-
[![
|
2
|
+
[![RPush Test](https://github.com/rpush/rpush/actions/workflows/test.yml/badge.svg)](https://github.com/rpush/rpush/actions/workflows/test.yml)
|
3
3
|
[![Test Coverage](https://codeclimate.com/github/rpush/rpush/badges/coverage.svg)](https://codeclimate.com/github/rpush/rpush)
|
4
4
|
[![Code Climate](https://codeclimate.com/github/rpush/rpush/badges/gpa.svg)](https://codeclimate.com/github/rpush/rpush)
|
5
5
|
[![Join the chat at https://gitter.im/rpush/rpush](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/rpush/rpush?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
@@ -58,7 +58,7 @@ There is a choice of two modes (and one legacy mode) using certificates or using
|
|
58
58
|
* `Rpush::Apns2` This requires an annually renewable certificate. see https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/establishing_a_certificate-based_connection_to_apns
|
59
59
|
* `Rpush::Apnsp8` This uses encrypted tokens and requires an encryption key id and encryption key (provide as a p8 file). (see https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/establishing_a_token-based_connection_to_apns)
|
60
60
|
* `Rpush::Apns` There is also the original APNS (the original version using certificates with a binary underlying protocol over TCP directly rather than over Http/2).
|
61
|
-
Apple have [announced](https://developer.apple.com/news/?id=
|
61
|
+
Apple have [announced](https://developer.apple.com/news/?id=c88acm2b) that this is not supported after March 31, 2021.
|
62
62
|
|
63
63
|
If this is your first time using the APNs, you will need to generate either SSL certificates (for Apns2 or Apns) or an Encryption Key (p8) and an Encryption Key ID (for Apnsp8). See [Generating Certificates](https://github.com/rpush/rpush/wiki/Generating-Certificates) for instructions.
|
64
64
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class AddAlertIsJsonToRapnsNotifications < ActiveRecord::
|
1
|
+
class AddAlertIsJsonToRapnsNotifications < ActiveRecord::Migration[5.0]
|
2
2
|
def self.up
|
3
3
|
add_column :rapns_notifications, :alert_is_json, :boolean, null: true, default: false
|
4
4
|
end
|
@@ -6,4 +6,4 @@ class AddAlertIsJsonToRapnsNotifications < ActiveRecord::VERSION::MAJOR >= 5 ? A
|
|
6
6
|
def self.down
|
7
7
|
remove_column :rapns_notifications, :alert_is_json
|
8
8
|
end
|
9
|
-
end
|
9
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class AddAppToRapns < ActiveRecord::
|
1
|
+
class AddAppToRapns < ActiveRecord::Migration[5.0]
|
2
2
|
def self.up
|
3
3
|
add_column :rapns_notifications, :app, :string, null: true
|
4
4
|
add_column :rapns_feedback, :app, :string, null: true
|
@@ -8,4 +8,4 @@ class AddAppToRapns < ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Migratio
|
|
8
8
|
remove_column :rapns_notifications, :app
|
9
9
|
remove_column :rapns_feedback, :app
|
10
10
|
end
|
11
|
-
end
|
11
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class AddFailAfterToRpushNotifications < ActiveRecord::
|
1
|
+
class AddFailAfterToRpushNotifications < ActiveRecord::Migration[5.0]
|
2
2
|
def self.up
|
3
3
|
add_column :rpush_notifications, :fail_after, :timestamp, null: true
|
4
4
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class AddGcm < ActiveRecord::
|
1
|
+
class AddGcm < ActiveRecord::Migration[5.0]
|
2
2
|
module Rapns
|
3
3
|
class App < ActiveRecord::Base
|
4
4
|
self.table_name = 'rapns_apps'
|
@@ -50,18 +50,10 @@ class AddGcm < ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Migration[5.0]
|
|
50
50
|
change_column :rapns_notifications, :app_id, :integer, null: false
|
51
51
|
remove_column :rapns_notifications, :app
|
52
52
|
|
53
|
-
if
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
remove_index :rapns_notifications, name: "index_rapns_notifications_on_delivered_failed_deliver_after"
|
58
|
-
end
|
59
|
-
else
|
60
|
-
if index_name_exists?(:rapns_notifications, "index_rapns_notifications_multi", true)
|
61
|
-
remove_index :rapns_notifications, name: "index_rapns_notifications_multi"
|
62
|
-
elsif index_name_exists?(:rapns_notifications, "index_rapns_notifications_on_delivered_failed_deliver_after", false)
|
63
|
-
remove_index :rapns_notifications, name: "index_rapns_notifications_on_delivered_failed_deliver_after"
|
64
|
-
end
|
53
|
+
if index_name_exists?(:rapns_notifications, "index_rapns_notifications_multi")
|
54
|
+
remove_index :rapns_notifications, name: "index_rapns_notifications_multi"
|
55
|
+
elsif index_name_exists?(:rapns_notifications, "index_rapns_notifications_on_delivered_failed_deliver_after")
|
56
|
+
remove_index :rapns_notifications, name: "index_rapns_notifications_on_delivered_failed_deliver_after"
|
65
57
|
end
|
66
58
|
|
67
59
|
add_index :rapns_notifications, [:app_id, :delivered, :failed, :deliver_after], name: "index_rapns_notifications_multi"
|
@@ -100,14 +92,8 @@ class AddGcm < ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Migration[5.0]
|
|
100
92
|
AddGcm::Rapns::Notification.update_all(['app = ?', app.key], ['app_id = ?', app.id])
|
101
93
|
end
|
102
94
|
|
103
|
-
if
|
104
|
-
|
105
|
-
remove_index :rapns_notifications, name: :index_rapns_notifications_multi
|
106
|
-
end
|
107
|
-
else
|
108
|
-
if index_name_exists?(:rapns_notifications, :index_rapns_notifications_multi, true)
|
109
|
-
remove_index :rapns_notifications, name: :index_rapns_notifications_multi
|
110
|
-
end
|
95
|
+
if index_name_exists?(:rapns_notifications, :index_rapns_notifications_multi)
|
96
|
+
remove_index :rapns_notifications, name: :index_rapns_notifications_multi
|
111
97
|
end
|
112
98
|
|
113
99
|
remove_column :rapns_notifications, :app_id
|
@@ -19,7 +19,7 @@
|
|
19
19
|
# approach. The constituent parts of this migration have been executed
|
20
20
|
# many times, by many people!
|
21
21
|
|
22
|
-
class AddRpush < ActiveRecord::
|
22
|
+
class AddRpush < ActiveRecord::Migration[5.0]
|
23
23
|
def self.migrations
|
24
24
|
[CreateRapnsNotifications, CreateRapnsFeedback,
|
25
25
|
AddAlertIsJsonToRapnsNotifications, AddAppToRapns,
|
@@ -41,7 +41,7 @@ class AddRpush < ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Migration[5.0
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
class CreateRapnsNotifications < ActiveRecord::
|
44
|
+
class CreateRapnsNotifications < ActiveRecord::Migration[5.0]
|
45
45
|
def self.up
|
46
46
|
create_table :rapns_notifications do |t|
|
47
47
|
t.integer :badge, null: true
|
@@ -64,21 +64,15 @@ class AddRpush < ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Migration[5.0
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def self.down
|
67
|
-
if
|
68
|
-
|
69
|
-
remove_index :rapns_notifications, name: 'index_rapns_notifications_multi'
|
70
|
-
end
|
71
|
-
else
|
72
|
-
if index_name_exists?(:rapns_notifications, 'index_rapns_notifications_multi', true)
|
73
|
-
remove_index :rapns_notifications, name: 'index_rapns_notifications_multi'
|
74
|
-
end
|
67
|
+
if index_name_exists?(:rapns_notifications, 'index_rapns_notifications_multi')
|
68
|
+
remove_index :rapns_notifications, name: 'index_rapns_notifications_multi'
|
75
69
|
end
|
76
70
|
|
77
71
|
drop_table :rapns_notifications
|
78
72
|
end
|
79
73
|
end
|
80
74
|
|
81
|
-
class CreateRapnsFeedback < ActiveRecord::
|
75
|
+
class CreateRapnsFeedback < ActiveRecord::Migration[5.0]
|
82
76
|
def self.up
|
83
77
|
create_table :rapns_feedback do |t|
|
84
78
|
t.string :device_token, null: false, limit: 64
|
@@ -90,21 +84,15 @@ class AddRpush < ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Migration[5.0
|
|
90
84
|
end
|
91
85
|
|
92
86
|
def self.down
|
93
|
-
if
|
94
|
-
|
95
|
-
remove_index :rapns_feedback, name: :index_rapns_feedback_on_device_token
|
96
|
-
end
|
97
|
-
else
|
98
|
-
if index_name_exists?(:rapns_feedback, :index_rapns_feedback_on_device_token, true)
|
99
|
-
remove_index :rapns_feedback, name: :index_rapns_feedback_on_device_token
|
100
|
-
end
|
87
|
+
if index_name_exists?(:rapns_feedback, :index_rapns_feedback_on_device_token)
|
88
|
+
remove_index :rapns_feedback, name: :index_rapns_feedback_on_device_token
|
101
89
|
end
|
102
90
|
|
103
91
|
drop_table :rapns_feedback
|
104
92
|
end
|
105
93
|
end
|
106
94
|
|
107
|
-
class AddAlertIsJsonToRapnsNotifications < ActiveRecord::
|
95
|
+
class AddAlertIsJsonToRapnsNotifications < ActiveRecord::Migration[5.0]
|
108
96
|
def self.up
|
109
97
|
add_column :rapns_notifications, :alert_is_json, :boolean, null: true, default: false
|
110
98
|
end
|
@@ -114,7 +102,7 @@ class AddRpush < ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Migration[5.0
|
|
114
102
|
end
|
115
103
|
end
|
116
104
|
|
117
|
-
class AddAppToRapns < ActiveRecord::
|
105
|
+
class AddAppToRapns < ActiveRecord::Migration[5.0]
|
118
106
|
def self.up
|
119
107
|
add_column :rapns_notifications, :app, :string, null: true
|
120
108
|
add_column :rapns_feedback, :app, :string, null: true
|
@@ -126,7 +114,7 @@ class AddRpush < ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Migration[5.0
|
|
126
114
|
end
|
127
115
|
end
|
128
116
|
|
129
|
-
class CreateRapnsApps < ActiveRecord::
|
117
|
+
class CreateRapnsApps < ActiveRecord::Migration[5.0]
|
130
118
|
def self.up
|
131
119
|
create_table :rapns_apps do |t|
|
132
120
|
t.string :key, null: false
|
@@ -143,7 +131,7 @@ class AddRpush < ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Migration[5.0
|
|
143
131
|
end
|
144
132
|
end
|
145
133
|
|
146
|
-
class AddGcm < ActiveRecord::
|
134
|
+
class AddGcm < ActiveRecord::Migration[5.0]
|
147
135
|
module Rapns
|
148
136
|
class App < ActiveRecord::Base
|
149
137
|
self.table_name = 'rapns_apps'
|
@@ -195,18 +183,10 @@ class AddRpush < ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Migration[5.0
|
|
195
183
|
change_column :rapns_notifications, :app_id, :integer, null: false
|
196
184
|
remove_column :rapns_notifications, :app
|
197
185
|
|
198
|
-
if
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
remove_index :rapns_notifications, name: "index_rapns_notifications_on_delivered_failed_deliver_after"
|
203
|
-
end
|
204
|
-
else
|
205
|
-
if index_name_exists?(:rapns_notifications, "index_rapns_notifications_multi", true)
|
206
|
-
remove_index :rapns_notifications, name: "index_rapns_notifications_multi"
|
207
|
-
elsif index_name_exists?(:rapns_notifications, "index_rapns_notifications_on_delivered_failed_deliver_after", false)
|
208
|
-
remove_index :rapns_notifications, name: "index_rapns_notifications_on_delivered_failed_deliver_after"
|
209
|
-
end
|
186
|
+
if index_name_exists?(:rapns_notifications, "index_rapns_notifications_multi")
|
187
|
+
remove_index :rapns_notifications, name: "index_rapns_notifications_multi"
|
188
|
+
elsif index_name_exists?(:rapns_notifications, "index_rapns_notifications_on_delivered_failed_deliver_after")
|
189
|
+
remove_index :rapns_notifications, name: "index_rapns_notifications_on_delivered_failed_deliver_after"
|
210
190
|
end
|
211
191
|
|
212
192
|
add_index :rapns_notifications, [:app_id, :delivered, :failed, :deliver_after], name: "index_rapns_notifications_multi"
|
@@ -245,14 +225,8 @@ class AddRpush < ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Migration[5.0
|
|
245
225
|
AddGcm::Rapns::Notification.where(app_id: app.id).update_all(app: app.key)
|
246
226
|
end
|
247
227
|
|
248
|
-
if
|
249
|
-
|
250
|
-
remove_index :rapns_notifications, name: :index_rapns_notifications_multi
|
251
|
-
end
|
252
|
-
else
|
253
|
-
if index_name_exists?(:rapns_notifications, :index_rapns_notifications_multi, true)
|
254
|
-
remove_index :rapns_notifications, name: :index_rapns_notifications_multi
|
255
|
-
end
|
228
|
+
if index_name_exists?(:rapns_notifications, :index_rapns_notifications_multi)
|
229
|
+
remove_index :rapns_notifications, name: :index_rapns_notifications_multi
|
256
230
|
end
|
257
231
|
|
258
232
|
remove_column :rapns_notifications, :app_id
|
@@ -261,7 +235,7 @@ class AddRpush < ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Migration[5.0
|
|
261
235
|
end
|
262
236
|
end
|
263
237
|
|
264
|
-
class AddWpns < ActiveRecord::
|
238
|
+
class AddWpns < ActiveRecord::Migration[5.0]
|
265
239
|
module Rapns
|
266
240
|
class Notification < ActiveRecord::Base
|
267
241
|
self.table_name = 'rapns_notifications'
|
@@ -278,7 +252,7 @@ class AddRpush < ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Migration[5.0
|
|
278
252
|
end
|
279
253
|
end
|
280
254
|
|
281
|
-
class AddAdm < ActiveRecord::
|
255
|
+
class AddAdm < ActiveRecord::Migration[5.0]
|
282
256
|
module Rapns
|
283
257
|
class Notification < ActiveRecord::Base
|
284
258
|
self.table_name = 'rapns_notifications'
|
@@ -302,7 +276,7 @@ class AddRpush < ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Migration[5.0
|
|
302
276
|
end
|
303
277
|
end
|
304
278
|
|
305
|
-
class RenameRapnsToRpush < ActiveRecord::
|
279
|
+
class RenameRapnsToRpush < ActiveRecord::Migration[5.0]
|
306
280
|
module Rpush
|
307
281
|
class App < ActiveRecord::Base
|
308
282
|
self.table_name = 'rpush_apps'
|
@@ -322,24 +296,12 @@ class AddRpush < ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Migration[5.0
|
|
322
296
|
rename_table :rapns_apps, :rpush_apps
|
323
297
|
rename_table :rapns_feedback, :rpush_feedback
|
324
298
|
|
325
|
-
if
|
326
|
-
|
327
|
-
rename_index :rpush_notifications, :index_rapns_notifications_multi, :index_rpush_notifications_multi
|
328
|
-
end
|
329
|
-
else
|
330
|
-
if index_name_exists?(:rpush_notifications, :index_rapns_notifications_multi, true)
|
331
|
-
rename_index :rpush_notifications, :index_rapns_notifications_multi, :index_rpush_notifications_multi
|
332
|
-
end
|
299
|
+
if index_name_exists?(:rpush_notifications, :index_rapns_notifications_multi)
|
300
|
+
rename_index :rpush_notifications, :index_rapns_notifications_multi, :index_rpush_notifications_multi
|
333
301
|
end
|
334
302
|
|
335
|
-
if
|
336
|
-
|
337
|
-
rename_index :rpush_feedback, :index_rapns_feedback_on_device_token, :index_rpush_feedback_on_device_token
|
338
|
-
end
|
339
|
-
else
|
340
|
-
if index_name_exists?(:rpush_feedback, :index_rapns_feedback_on_device_token, true)
|
341
|
-
rename_index :rpush_feedback, :index_rapns_feedback_on_device_token, :index_rpush_feedback_on_device_token
|
342
|
-
end
|
303
|
+
if index_name_exists?(:rpush_feedback, :index_rapns_feedback_on_device_token)
|
304
|
+
rename_index :rpush_feedback, :index_rapns_feedback_on_device_token, :index_rpush_feedback_on_device_token
|
343
305
|
end
|
344
306
|
|
345
307
|
update_type(RenameRapnsToRpush::Rpush::Notification, 'Rapns::Apns::Notification', 'Rpush::Apns::Notification')
|
@@ -364,24 +326,12 @@ class AddRpush < ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Migration[5.0
|
|
364
326
|
update_type(RenameRapnsToRpush::Rpush::App, 'Rpush::Adm::App', 'Rapns::Adm::App')
|
365
327
|
update_type(RenameRapnsToRpush::Rpush::App, 'Rpush::Wpns::App', 'Rapns::Wpns::App')
|
366
328
|
|
367
|
-
if
|
368
|
-
|
369
|
-
rename_index :rpush_notifications, :index_rpush_notifications_multi, :index_rapns_notifications_multi
|
370
|
-
end
|
371
|
-
else
|
372
|
-
if index_name_exists?(:rpush_notifications, :index_rpush_notifications_multi, true)
|
373
|
-
rename_index :rpush_notifications, :index_rpush_notifications_multi, :index_rapns_notifications_multi
|
374
|
-
end
|
329
|
+
if index_name_exists?(:rpush_notifications, :index_rpush_notifications_multi)
|
330
|
+
rename_index :rpush_notifications, :index_rpush_notifications_multi, :index_rapns_notifications_multi
|
375
331
|
end
|
376
332
|
|
377
|
-
if
|
378
|
-
|
379
|
-
rename_index :rpush_feedback, :index_rpush_feedback_on_device_token, :index_rapns_feedback_on_device_token
|
380
|
-
end
|
381
|
-
else
|
382
|
-
if index_name_exists?(:rpush_feedback, :index_rpush_feedback_on_device_token, true)
|
383
|
-
rename_index :rpush_feedback, :index_rpush_feedback_on_device_token, :index_rapns_feedback_on_device_token
|
384
|
-
end
|
333
|
+
if index_name_exists?(:rpush_feedback, :index_rpush_feedback_on_device_token)
|
334
|
+
rename_index :rpush_feedback, :index_rpush_feedback_on_device_token, :index_rapns_feedback_on_device_token
|
385
335
|
end
|
386
336
|
|
387
337
|
rename_table :rpush_notifications, :rapns_notifications
|
@@ -390,7 +340,7 @@ class AddRpush < ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Migration[5.0
|
|
390
340
|
end
|
391
341
|
end
|
392
342
|
|
393
|
-
class AddFailAfterToRpushNotifications < ActiveRecord::
|
343
|
+
class AddFailAfterToRpushNotifications < ActiveRecord::Migration[5.0]
|
394
344
|
def self.up
|
395
345
|
add_column :rpush_notifications, :fail_after, :timestamp, null: true
|
396
346
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class CreateRapnsFeedback < ActiveRecord::
|
1
|
+
class CreateRapnsFeedback < ActiveRecord::Migration[5.0]
|
2
2
|
def self.up
|
3
3
|
create_table :rapns_feedback do |t|
|
4
4
|
t.string :device_token, null: false, limit: 64
|
@@ -10,14 +10,8 @@ class CreateRapnsFeedback < ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Mi
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.down
|
13
|
-
if
|
14
|
-
|
15
|
-
remove_index :rapns_feedback, name: :index_rapns_feedback_on_device_token
|
16
|
-
end
|
17
|
-
else
|
18
|
-
if index_name_exists?(:rapns_feedback, :index_rapns_feedback_on_device_token, true)
|
19
|
-
remove_index :rapns_feedback, name: :index_rapns_feedback_on_device_token
|
20
|
-
end
|
13
|
+
if index_name_exists?(:rapns_feedback, :index_rapns_feedback_on_device_token)
|
14
|
+
remove_index :rapns_feedback, name: :index_rapns_feedback_on_device_token
|
21
15
|
end
|
22
16
|
|
23
17
|
drop_table :rapns_feedback
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class CreateRapnsNotifications < ActiveRecord::
|
1
|
+
class CreateRapnsNotifications < ActiveRecord::Migration[5.0]
|
2
2
|
def self.up
|
3
3
|
create_table :rapns_notifications do |t|
|
4
4
|
t.integer :badge, null: true
|
@@ -21,14 +21,8 @@ class CreateRapnsNotifications < ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecor
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.down
|
24
|
-
if
|
25
|
-
|
26
|
-
remove_index :rapns_notifications, name: 'index_rapns_notifications_multi'
|
27
|
-
end
|
28
|
-
else
|
29
|
-
if index_name_exists?(:rapns_notifications, 'index_rapns_notifications_multi', true)
|
30
|
-
remove_index :rapns_notifications, name: 'index_rapns_notifications_multi'
|
31
|
-
end
|
24
|
+
if index_name_exists?(:rapns_notifications, 'index_rapns_notifications_multi')
|
25
|
+
remove_index :rapns_notifications, name: 'index_rapns_notifications_multi'
|
32
26
|
end
|
33
27
|
|
34
28
|
drop_table :rapns_notifications
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class RenameRapnsToRpush < ActiveRecord::
|
1
|
+
class RenameRapnsToRpush < ActiveRecord::Migration[5.0]
|
2
2
|
module Rpush
|
3
3
|
class App < ActiveRecord::Base
|
4
4
|
self.table_name = 'rpush_apps'
|
@@ -18,24 +18,12 @@ class RenameRapnsToRpush < ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Mig
|
|
18
18
|
rename_table :rapns_apps, :rpush_apps
|
19
19
|
rename_table :rapns_feedback, :rpush_feedback
|
20
20
|
|
21
|
-
if
|
22
|
-
|
23
|
-
rename_index :rpush_notifications, :index_rapns_notifications_multi, :index_rpush_notifications_multi
|
24
|
-
end
|
25
|
-
else
|
26
|
-
if index_name_exists?(:rpush_notifications, :index_rapns_notifications_multi, true)
|
27
|
-
rename_index :rpush_notifications, :index_rapns_notifications_multi, :index_rpush_notifications_multi
|
28
|
-
end
|
21
|
+
if index_name_exists?(:rpush_notifications, :index_rapns_notifications_multi)
|
22
|
+
rename_index :rpush_notifications, :index_rapns_notifications_multi, :index_rpush_notifications_multi
|
29
23
|
end
|
30
24
|
|
31
|
-
if
|
32
|
-
|
33
|
-
rename_index :rpush_feedback, :index_rapns_feedback_on_device_token, :index_rpush_feedback_on_device_token
|
34
|
-
end
|
35
|
-
else
|
36
|
-
if index_name_exists?(:rpush_feedback, :index_rapns_feedback_on_device_token, true)
|
37
|
-
rename_index :rpush_feedback, :index_rapns_feedback_on_device_token, :index_rpush_feedback_on_device_token
|
38
|
-
end
|
25
|
+
if index_name_exists?(:rpush_feedback, :index_rapns_feedback_on_device_token)
|
26
|
+
rename_index :rpush_feedback, :index_rapns_feedback_on_device_token, :index_rpush_feedback_on_device_token
|
39
27
|
end
|
40
28
|
|
41
29
|
update_type(RenameRapnsToRpush::Rpush::Notification, 'Rapns::Apns::Notification', 'Rpush::Apns::Notification')
|
@@ -60,24 +48,12 @@ class RenameRapnsToRpush < ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Mig
|
|
60
48
|
update_type(RenameRapnsToRpush::Rpush::App, 'Rpush::Adm::App', 'Rapns::Adm::App')
|
61
49
|
update_type(RenameRapnsToRpush::Rpush::App, 'Rpush::Wpns::App', 'Rapns::Wpns::App')
|
62
50
|
|
63
|
-
if
|
64
|
-
|
65
|
-
rename_index :rpush_notifications, :index_rpush_notifications_multi, :index_rapns_notifications_multi
|
66
|
-
end
|
67
|
-
else
|
68
|
-
if index_name_exists?(:rpush_notifications, :index_rpush_notifications_multi, true)
|
69
|
-
rename_index :rpush_notifications, :index_rpush_notifications_multi, :index_rapns_notifications_multi
|
70
|
-
end
|
51
|
+
if index_name_exists?(:rpush_notifications, :index_rpush_notifications_multi)
|
52
|
+
rename_index :rpush_notifications, :index_rpush_notifications_multi, :index_rapns_notifications_multi
|
71
53
|
end
|
72
54
|
|
73
|
-
if
|
74
|
-
|
75
|
-
rename_index :rpush_feedback, :index_rpush_feedback_on_device_token, :index_rapns_feedback_on_device_token
|
76
|
-
end
|
77
|
-
else
|
78
|
-
if index_name_exists?(:rpush_feedback, :index_rpush_feedback_on_device_token, true)
|
79
|
-
rename_index :rpush_feedback, :index_rpush_feedback_on_device_token, :index_rapns_feedback_on_device_token
|
80
|
-
end
|
55
|
+
if index_name_exists?(:rpush_feedback, :index_rpush_feedback_on_device_token)
|
56
|
+
rename_index :rpush_feedback, :index_rpush_feedback_on_device_token, :index_rapns_feedback_on_device_token
|
81
57
|
end
|
82
58
|
|
83
59
|
rename_table :rpush_notifications, :rapns_notifications
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class Rpush200Updates < ActiveRecord::
|
1
|
+
class Rpush200Updates < ActiveRecord::Migration[5.0]
|
2
2
|
module Rpush
|
3
3
|
class App < ActiveRecord::Base
|
4
4
|
self.table_name = 'rpush_apps'
|
@@ -17,14 +17,8 @@ class Rpush200Updates < ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Migrat
|
|
17
17
|
add_column :rpush_notifications, :processing, :boolean, null: false, default: false
|
18
18
|
add_column :rpush_notifications, :priority, :integer, null: true
|
19
19
|
|
20
|
-
if
|
21
|
-
|
22
|
-
remove_index :rpush_notifications, name: :index_rpush_notifications_multi
|
23
|
-
end
|
24
|
-
else
|
25
|
-
if index_name_exists?(:rpush_notifications, :index_rpush_notifications_multi, true)
|
26
|
-
remove_index :rpush_notifications, name: :index_rpush_notifications_multi
|
27
|
-
end
|
20
|
+
if index_name_exists?(:rpush_notifications, :index_rpush_notifications_multi)
|
21
|
+
remove_index :rpush_notifications, name: :index_rpush_notifications_multi
|
28
22
|
end
|
29
23
|
|
30
24
|
add_index :rpush_notifications, [:delivered, :failed], name: 'index_rpush_notifications_multi', where: 'NOT delivered AND NOT failed'
|
@@ -52,14 +46,8 @@ class Rpush200Updates < ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Migrat
|
|
52
46
|
change_column :rpush_feedback, :app_id, :string
|
53
47
|
rename_column :rpush_feedback, :app_id, :app
|
54
48
|
|
55
|
-
if
|
56
|
-
|
57
|
-
remove_index :rpush_notifications, name: :index_rpush_notifications_multi
|
58
|
-
end
|
59
|
-
else
|
60
|
-
if index_name_exists?(:rpush_notifications, :index_rpush_notifications_multi, true)
|
61
|
-
remove_index :rpush_notifications, name: :index_rpush_notifications_multi
|
62
|
-
end
|
49
|
+
if index_name_exists?(:rpush_notifications, :index_rpush_notifications_multi)
|
50
|
+
remove_index :rpush_notifications, name: :index_rpush_notifications_multi
|
63
51
|
end
|
64
52
|
|
65
53
|
add_index :rpush_notifications, [:app_id, :delivered, :failed, :deliver_after], name: 'index_rpush_notifications_multi'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class Rpush210Updates < ActiveRecord::
|
1
|
+
class Rpush210Updates < ActiveRecord::Migration[5.0]
|
2
2
|
def self.up
|
3
3
|
add_column :rpush_notifications, :url_args, :text, null: true
|
4
4
|
add_column :rpush_notifications, :category, :string, null: true
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class Rpush270Updates < ActiveRecord::
|
1
|
+
class Rpush270Updates < ActiveRecord::Migration[5.0]
|
2
2
|
def self.up
|
3
3
|
change_column :rpush_notifications, :alert, :text
|
4
4
|
add_column :rpush_notifications, :notification, :text
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class Rpush300Updates < ActiveRecord::
|
1
|
+
class Rpush300Updates < ActiveRecord::Migration[5.0]
|
2
2
|
def self.up
|
3
3
|
add_column :rpush_notifications, :mutable_content, :boolean, default: false
|
4
4
|
change_column :rpush_notifications, :sound, :string, default: nil
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class Rpush301Updates < ActiveRecord::
|
1
|
+
class Rpush301Updates < ActiveRecord::Migration[5.0]
|
2
2
|
def self.up
|
3
3
|
change_column_null :rpush_notifications, :mutable_content, false
|
4
4
|
change_column_null :rpush_notifications, :content_available, false
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class Rpush311Updates < ActiveRecord::
|
1
|
+
class Rpush311Updates < ActiveRecord::Migration[5.0]
|
2
2
|
def self.up
|
3
3
|
change_table :rpush_notifications do |t|
|
4
4
|
t.remove_index name: 'index_rpush_notifications_multi'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class Rpush320AddApnsP8 < ActiveRecord::
|
1
|
+
class Rpush320AddApnsP8 < ActiveRecord::Migration[5.0]
|
2
2
|
def self.up
|
3
3
|
add_column :rpush_apps, :apn_key, :string, null: true
|
4
4
|
add_column :rpush_apps, :apn_key_id, :string, null: true
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class Rpush331Updates < ActiveRecord::
|
1
|
+
class Rpush331Updates < ActiveRecord::Migration[5.0]
|
2
2
|
def self.up
|
3
3
|
change_column :rpush_notifications, :device_token, :string, null: true
|
4
4
|
change_column :rpush_feedback, :device_token, :string, null: true
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class Rpush410Updates < ActiveRecord::
|
1
|
+
class Rpush410Updates < ActiveRecord::Migration["#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}"]
|
2
2
|
def self.up
|
3
3
|
add_column :rpush_notifications, :dry_run, :boolean, null: false, default: false
|
4
4
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class Rpush411Updates < ActiveRecord::
|
1
|
+
class Rpush411Updates < ActiveRecord::Migration["#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}"]
|
2
2
|
def self.up
|
3
3
|
add_column :rpush_apps, :feedback_enabled, :boolean, default: true
|
4
4
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class Rpush420Updates < ActiveRecord::
|
1
|
+
class Rpush420Updates < ActiveRecord::Migration["#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}"]
|
2
2
|
def self.up
|
3
3
|
add_column :rpush_notifications, :sound_is_json, :boolean, null: true, default: false
|
4
4
|
end
|
@@ -3,6 +3,7 @@ require 'active_model'
|
|
3
3
|
require 'rpush/client/active_model/notification'
|
4
4
|
require 'rpush/client/active_model/payload_data_size_validator'
|
5
5
|
require 'rpush/client/active_model/registration_ids_count_validator'
|
6
|
+
require 'rpush/client/active_model/certificate_private_key_validator'
|
6
7
|
|
7
8
|
require 'rpush/client/active_model/apns/device_token_format_validator'
|
8
9
|
require 'rpush/client/active_model/apns/app'
|
@@ -7,29 +7,13 @@ module Rpush
|
|
7
7
|
base.instance_eval do
|
8
8
|
validates :environment, presence: true, inclusion: { in: %w(development production sandbox) }
|
9
9
|
validates :certificate, presence: true
|
10
|
-
|
10
|
+
validates_with Rpush::Client::ActiveModel::CertificatePrivateKeyValidator
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
def service_name
|
15
15
|
'apns'
|
16
16
|
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def certificate_has_matching_private_key
|
21
|
-
result = false
|
22
|
-
if certificate.present?
|
23
|
-
begin
|
24
|
-
x509 = OpenSSL::X509::Certificate.new(certificate)
|
25
|
-
pkey = OpenSSL::PKey::RSA.new(certificate, password)
|
26
|
-
result = x509 && pkey
|
27
|
-
rescue OpenSSL::OpenSSLError
|
28
|
-
errors.add :certificate, 'value must contain a certificate and a private key.'
|
29
|
-
end
|
30
|
-
end
|
31
|
-
result
|
32
|
-
end
|
33
17
|
end
|
34
18
|
end
|
35
19
|
end
|
@@ -52,6 +52,10 @@ module Rpush
|
|
52
52
|
self.data = (data || {}).merge(CONTENT_AVAILABLE_KEY => true)
|
53
53
|
end
|
54
54
|
|
55
|
+
def content_available?
|
56
|
+
(self.data || {})[CONTENT_AVAILABLE_KEY]
|
57
|
+
end
|
58
|
+
|
55
59
|
def as_json(options = nil) # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
|
56
60
|
json = ActiveSupport::OrderedHash.new
|
57
61
|
|
@@ -3,7 +3,13 @@ module Rpush
|
|
3
3
|
module ActiveModel
|
4
4
|
module Apns2
|
5
5
|
module App
|
6
|
-
|
6
|
+
def self.included(base)
|
7
|
+
base.instance_eval do
|
8
|
+
validates :environment, presence: true, inclusion: { in: %w(development production sandbox) }
|
9
|
+
validates :certificate, presence: true
|
10
|
+
validates_with Rpush::Client::ActiveModel::CertificatePrivateKeyValidator
|
11
|
+
end
|
12
|
+
end
|
7
13
|
|
8
14
|
def service_name
|
9
15
|
'apns2'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Rpush
|
2
|
+
module Client
|
3
|
+
module ActiveModel
|
4
|
+
class CertificatePrivateKeyValidator < ::ActiveModel::Validator
|
5
|
+
def validate(record)
|
6
|
+
if record.certificate.present?
|
7
|
+
begin
|
8
|
+
x509 = OpenSSL::X509::Certificate.new(record.certificate)
|
9
|
+
pkey = OpenSSL::PKey::RSA.new(record.certificate, record.password)
|
10
|
+
x509 && pkey
|
11
|
+
rescue OpenSSL::OpenSSLError
|
12
|
+
record.errors.add :certificate, 'value must contain a certificate and a private key.'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -112,6 +112,7 @@ module Rpush
|
|
112
112
|
headers['apns-expiration'] = '0'
|
113
113
|
headers['apns-priority'] = '10'
|
114
114
|
headers['apns-topic'] = @app.bundle_id
|
115
|
+
headers['apns-push-type'] = 'background' if notification.content_available?
|
115
116
|
|
116
117
|
headers.merge notification_data(notification)[HTTP2_HEADERS_KEY] || {}
|
117
118
|
end
|
@@ -8,6 +8,7 @@ module Rpush
|
|
8
8
|
class Delivery < Rpush::Daemon::Delivery
|
9
9
|
RETRYABLE_CODES = [ 429, 500, 503 ]
|
10
10
|
CLIENT_JOIN_TIMEOUT = 60
|
11
|
+
DEFAULT_MAX_CONCURRENT_STREAMS = 100
|
11
12
|
|
12
13
|
def initialize(app, http2_client, token_provider, batch)
|
13
14
|
@app = app
|
@@ -85,7 +86,11 @@ module Rpush
|
|
85
86
|
def remote_max_concurrent_streams
|
86
87
|
# 0x7fffffff is the default value from http-2 gem (2^31)
|
87
88
|
if @client.remote_settings[:settings_max_concurrent_streams] == 0x7fffffff
|
88
|
-
|
89
|
+
# Ideally we'd fall back to `#local_settings` here, but `NetHttp2::Client`
|
90
|
+
# doesn't expose that attr from the `HTTP2::Client` it wraps. Instead, we
|
91
|
+
# chose a hard-coded value matching the default local setting from the
|
92
|
+
# `HTTP2::Client` class
|
93
|
+
DEFAULT_MAX_CONCURRENT_STREAMS
|
89
94
|
else
|
90
95
|
@client.remote_settings[:settings_max_concurrent_streams]
|
91
96
|
end
|
@@ -144,6 +149,7 @@ module Rpush
|
|
144
149
|
headers['apns-priority'] = '10'
|
145
150
|
headers['apns-topic'] = @app.bundle_id
|
146
151
|
headers['authorization'] = "bearer #{jwt_token}"
|
152
|
+
headers['apns-push-type'] = 'background' if notification.content_available?
|
147
153
|
|
148
154
|
headers.merge notification_data(notification)[HTTP2_HEADERS_KEY] || {}
|
149
155
|
end
|
data/lib/rpush/version.rb
CHANGED
@@ -79,7 +79,8 @@ describe 'APNs http2 adapter' do
|
|
79
79
|
headers: {
|
80
80
|
'apns-expiration' => '0',
|
81
81
|
'apns-priority' => '10',
|
82
|
-
'apns-topic' => 'com.example.app'
|
82
|
+
'apns-topic' => 'com.example.app',
|
83
|
+
'apns-push-type' => 'background'
|
83
84
|
}
|
84
85
|
}
|
85
86
|
)
|
@@ -113,7 +114,8 @@ describe 'APNs http2 adapter' do
|
|
113
114
|
headers: {
|
114
115
|
'apns-topic' => bundle_id,
|
115
116
|
'apns-expiration' => '0',
|
116
|
-
'apns-priority' => '10'
|
117
|
+
'apns-priority' => '10',
|
118
|
+
'apns-push-type' => 'background'
|
117
119
|
}
|
118
120
|
}
|
119
121
|
).and_return(fake_http2_request)
|
data/spec/spec_helper.rb
CHANGED
@@ -6,14 +6,15 @@ SPEC_ADAPTER = ENV['ADAPTER'] || 'postgresql'
|
|
6
6
|
SPEC_ADAPTER = 'jdbc' + SPEC_ADAPTER if jruby
|
7
7
|
|
8
8
|
require 'yaml'
|
9
|
-
|
9
|
+
db_config_path = File.expand_path("config/database.yml", File.dirname(__FILE__))
|
10
|
+
db_config = YAML.load(ERB.new(File.read(db_config_path)).result)
|
10
11
|
|
11
12
|
if db_config[SPEC_ADAPTER].nil?
|
12
13
|
puts "No such adapter '#{SPEC_ADAPTER}'. Valid adapters are #{db_config.keys.join(', ')}."
|
13
14
|
exit 1
|
14
15
|
end
|
15
16
|
|
16
|
-
if ENV['
|
17
|
+
if ENV['CI']
|
17
18
|
db_config[SPEC_ADAPTER]['username'] = 'postgres'
|
18
19
|
else
|
19
20
|
require 'etc'
|
@@ -62,7 +63,7 @@ migrations = [
|
|
62
63
|
Rpush420Updates
|
63
64
|
]
|
64
65
|
|
65
|
-
unless ENV['
|
66
|
+
unless ENV['CI']
|
66
67
|
migrations.reverse_each do |m|
|
67
68
|
begin
|
68
69
|
m.down
|
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
postgresql:
|
4
4
|
adapter: postgresql
|
5
|
-
database: rpush_test
|
6
|
-
host: localhost
|
7
|
-
username: postgres
|
8
|
-
password:
|
5
|
+
database: <%= ENV.fetch('POSTGRES_DB', 'rpush_test') %>
|
6
|
+
host: <%= ENV.fetch('POSTGRES_HOST', 'localhost') %>
|
7
|
+
username: <%= ENV.fetch('POSTGRES_USER', 'postgres') %>
|
8
|
+
password: <%= ENV.fetch('PGPASSWORD', '') %>
|
9
9
|
|
10
10
|
jdbcpostgresql:
|
11
11
|
adapter: jdbcpostgresql
|
@@ -8,7 +8,7 @@ describe Rpush::Client::ActiveRecord::Apns::Notification do
|
|
8
8
|
|
9
9
|
it "should validate the length of the binary conversion of the notification" do
|
10
10
|
notification = described_class.new
|
11
|
-
notification.app = Rpush::Apns2::App.create(name: 'test', environment: 'development')
|
11
|
+
notification.app = Rpush::Apns2::App.create(name: 'test', environment: 'development', certificate: TEST_CERT)
|
12
12
|
notification.device_token = "a" * 108
|
13
13
|
notification.alert = ""
|
14
14
|
|
@@ -8,7 +8,7 @@ describe Rpush::Client::ActiveRecord::Apns2::Notification do
|
|
8
8
|
|
9
9
|
it "should validate the length of the binary conversion of the notification" do
|
10
10
|
notification = described_class.new
|
11
|
-
notification.app = Rpush::Apns2::App.create(name: 'test', environment: 'development')
|
11
|
+
notification.app = Rpush::Apns2::App.create(name: 'test', environment: 'development', certificate: TEST_CERT)
|
12
12
|
notification.device_token = "a" * 108
|
13
13
|
notification.alert = ""
|
14
14
|
|
@@ -7,7 +7,7 @@ describe Rpush::Client::Redis::Apns::Notification do
|
|
7
7
|
|
8
8
|
it "should validate the length of the binary conversion of the notification" do
|
9
9
|
notification = described_class.new
|
10
|
-
notification.app = Rpush::Apns2::App.create(name: 'test', environment: 'development')
|
10
|
+
notification.app = Rpush::Apns2::App.create(name: 'test', environment: 'development', certificate: TEST_CERT)
|
11
11
|
notification.device_token = "a" * 108
|
12
12
|
notification.alert = ""
|
13
13
|
|
@@ -7,7 +7,7 @@ describe Rpush::Client::Redis::Apns2::Notification do
|
|
7
7
|
|
8
8
|
it "should validate the length of the binary conversion of the notification" do
|
9
9
|
notification = described_class.new
|
10
|
-
notification.app = Rpush::Apns2::App.create(name: 'test', environment: 'development')
|
10
|
+
notification.app = Rpush::Apns2::App.create(name: 'test', environment: 'development', certificate: TEST_CERT)
|
11
11
|
notification.device_token = "a" * 108
|
12
12
|
notification.alert = ""
|
13
13
|
|
@@ -165,6 +165,21 @@ shared_examples 'Rpush::Client::Apns::Notification' do
|
|
165
165
|
end
|
166
166
|
end
|
167
167
|
|
168
|
+
describe 'content_available?' do
|
169
|
+
context 'if not set' do
|
170
|
+
it 'should be false' do
|
171
|
+
expect(notification.content_available?).to be_falsey
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
context 'if set' do
|
176
|
+
it 'should be true' do
|
177
|
+
notification.content_available = true
|
178
|
+
expect(notification.content_available?).to be_truthy
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
168
183
|
describe 'url-args' do
|
169
184
|
it 'includes url-args in the payload' do
|
170
185
|
notification.url_args = ['url-arg-1']
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'unit_spec_helper'
|
2
|
+
|
3
|
+
describe Rpush::Daemon::Apnsp8::Delivery do
|
4
|
+
subject(:delivery) { described_class.new(app, http2_client, token_provider, batch) }
|
5
|
+
|
6
|
+
let(:app) { double(bundle_id: 'MY BUNDLE ID') }
|
7
|
+
let(:notification1) { double('Notification 1', data: {}, as_json: {}).as_null_object }
|
8
|
+
let(:notification2) { double('Notification 2', data: {}, as_json: {}).as_null_object }
|
9
|
+
|
10
|
+
let(:token_provider) { double(token: 'MY JWT TOKEN') }
|
11
|
+
let(:max_concurrent_streams) { 100 }
|
12
|
+
let(:remote_settings) { { settings_max_concurrent_streams: max_concurrent_streams } }
|
13
|
+
let(:http_request) { double(on: nil) }
|
14
|
+
let(:http2_client) do
|
15
|
+
double(
|
16
|
+
stream_count: 0,
|
17
|
+
call_async: nil,
|
18
|
+
join: nil,
|
19
|
+
prepare_request: http_request,
|
20
|
+
remote_settings: remote_settings
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
let(:batch) { double(mark_delivered: nil, all_processed: nil) }
|
25
|
+
let(:logger) { double(info: nil) }
|
26
|
+
|
27
|
+
before do
|
28
|
+
allow(batch).to receive(:each_notification) do |&blk|
|
29
|
+
[notification1, notification2].each(&blk)
|
30
|
+
end
|
31
|
+
allow(Rpush).to receive_messages(logger: logger)
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#perform' do
|
35
|
+
context 'with an HTTP2 client where max concurrent streams is not set' do
|
36
|
+
let(:max_concurrent_streams) { 0x7fffffff }
|
37
|
+
|
38
|
+
it 'does not fall into an infinite loop on notifications after the first' do
|
39
|
+
start = Time.now
|
40
|
+
thread = Thread.new { delivery.perform }
|
41
|
+
|
42
|
+
loop do
|
43
|
+
break unless thread.alive?
|
44
|
+
|
45
|
+
if Time.now - start > 0.5
|
46
|
+
thread.kill
|
47
|
+
fail 'Stuck in an infinite loop'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
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:
|
4
|
+
version: 6.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian Leitch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
@@ -78,14 +78,14 @@ dependencies:
|
|
78
78
|
requirements:
|
79
79
|
- - ">="
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: '5.
|
81
|
+
version: '5.2'
|
82
82
|
type: :runtime
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
86
|
- - ">="
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version: '5.
|
88
|
+
version: '5.2'
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
90
|
name: thor
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -428,6 +428,7 @@ files:
|
|
428
428
|
- lib/rpush/client/active_model/apns2/notification.rb
|
429
429
|
- lib/rpush/client/active_model/apnsp8/app.rb
|
430
430
|
- lib/rpush/client/active_model/apnsp8/notification.rb
|
431
|
+
- lib/rpush/client/active_model/certificate_private_key_validator.rb
|
431
432
|
- lib/rpush/client/active_model/gcm/app.rb
|
432
433
|
- lib/rpush/client/active_model/gcm/expiry_collapse_key_mutual_inclusion_validator.rb
|
433
434
|
- lib/rpush/client/active_model/gcm/notification.rb
|
@@ -650,6 +651,7 @@ files:
|
|
650
651
|
- spec/unit/daemon/apns/certificate_expired_error_spec.rb
|
651
652
|
- spec/unit/daemon/apns/delivery_spec.rb
|
652
653
|
- spec/unit/daemon/apns/feedback_receiver_spec.rb
|
654
|
+
- spec/unit/daemon/apnsp8/delivery_spec.rb
|
653
655
|
- spec/unit/daemon/app_runner_spec.rb
|
654
656
|
- spec/unit/daemon/batch_spec.rb
|
655
657
|
- spec/unit/daemon/delivery_error_spec.rb
|
@@ -692,7 +694,7 @@ metadata:
|
|
692
694
|
changelog_uri: https://github.com/rpush/rpush/blob/master/CHANGELOG.md
|
693
695
|
source_code_uri: https://github.com/rpush/rpush
|
694
696
|
post_install_message: |
|
695
|
-
When upgrading, don't forget to run `bundle exec rpush init` to get all the latest migrations.
|
697
|
+
When upgrading Rpush, don't forget to run `bundle exec rpush init` to get all the latest migrations.
|
696
698
|
|
697
699
|
For details on this specific release, refer to the CHANGELOG.md file.
|
698
700
|
https://github.com/rpush/rpush/blob/master/CHANGELOG.md
|
@@ -803,6 +805,7 @@ test_files:
|
|
803
805
|
- spec/unit/daemon/apns/certificate_expired_error_spec.rb
|
804
806
|
- spec/unit/daemon/apns/delivery_spec.rb
|
805
807
|
- spec/unit/daemon/apns/feedback_receiver_spec.rb
|
808
|
+
- spec/unit/daemon/apnsp8/delivery_spec.rb
|
806
809
|
- spec/unit/daemon/app_runner_spec.rb
|
807
810
|
- spec/unit/daemon/batch_spec.rb
|
808
811
|
- spec/unit/daemon/delivery_error_spec.rb
|