rpush 8.0.0 → 9.1.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 +20 -6
- data/README.md +8 -65
- data/lib/generators/templates/rpush.rb +9 -16
- data/lib/rpush/client/active_model/fcm/notification.rb +1 -0
- data/lib/rpush/client/active_model.rb +0 -4
- data/lib/rpush/client/active_record/notification.rb +2 -0
- data/lib/rpush/client/active_record.rb +0 -3
- data/lib/rpush/client/redis.rb +0 -3
- data/lib/rpush/configuration.rb +2 -19
- data/lib/rpush/daemon/service_config_methods.rb +0 -2
- data/lib/rpush/daemon/store/active_record.rb +2 -14
- data/lib/rpush/daemon/store/interface.rb +2 -2
- data/lib/rpush/daemon/store/redis.rb +2 -11
- data/lib/rpush/daemon.rb +0 -10
- data/lib/rpush/reflection_collection.rb +1 -2
- data/lib/rpush/version.rb +2 -2
- data/lib/rpush.rb +0 -1
- data/spec/functional/cli_spec.rb +41 -15
- data/spec/functional/embed_spec.rb +57 -26
- data/spec/functional/retry_spec.rb +21 -4
- data/spec/functional/synchronization_spec.rb +1 -1
- data/spec/functional_spec_helper.rb +0 -6
- data/spec/spec_helper.rb +17 -7
- data/spec/unit/client/active_record/shared/app.rb +1 -1
- data/spec/unit/client/shared/fcm/notification.rb +6 -1
- data/spec/unit/daemon/shared/store.rb +0 -42
- metadata +61 -61
- data/lib/rpush/apns_feedback.rb +0 -18
- data/lib/rpush/client/active_model/gcm/app.rb +0 -19
- data/lib/rpush/client/active_model/gcm/expiry_collapse_key_mutual_inclusion_validator.rb +0 -14
- data/lib/rpush/client/active_model/gcm/notification.rb +0 -62
- data/lib/rpush/client/active_record/gcm/app.rb +0 -11
- data/lib/rpush/client/active_record/gcm/notification.rb +0 -11
- data/lib/rpush/client/redis/gcm/app.rb +0 -11
- data/lib/rpush/client/redis/gcm/notification.rb +0 -11
- data/lib/rpush/daemon/apns/delivery.rb +0 -43
- data/lib/rpush/daemon/apns/feedback_receiver.rb +0 -91
- data/lib/rpush/daemon/apns.rb +0 -17
- data/lib/rpush/daemon/dispatcher/apns_tcp.rb +0 -152
- data/lib/rpush/daemon/dispatcher/tcp.rb +0 -22
- data/lib/rpush/daemon/gcm/delivery.rb +0 -241
- data/lib/rpush/daemon/gcm.rb +0 -9
- data/lib/rpush/daemon/tcp_connection.rb +0 -190
- data/spec/functional/apns_spec.rb +0 -162
- data/spec/functional/gcm_priority_spec.rb +0 -40
- data/spec/functional/gcm_spec.rb +0 -46
- data/spec/functional/new_app_spec.rb +0 -44
- data/spec/unit/apns_feedback_spec.rb +0 -39
- data/spec/unit/client/active_record/gcm/app_spec.rb +0 -6
- data/spec/unit/client/active_record/gcm/notification_spec.rb +0 -14
- data/spec/unit/client/redis/gcm/app_spec.rb +0 -5
- data/spec/unit/client/redis/gcm/notification_spec.rb +0 -5
- data/spec/unit/client/shared/gcm/app.rb +0 -4
- data/spec/unit/client/shared/gcm/notification.rb +0 -77
- data/spec/unit/daemon/apns/delivery_spec.rb +0 -108
- data/spec/unit/daemon/apns/feedback_receiver_spec.rb +0 -137
- data/spec/unit/daemon/dispatcher/tcp_spec.rb +0 -32
- data/spec/unit/daemon/gcm/delivery_spec.rb +0 -387
- data/spec/unit/daemon/tcp_connection_spec.rb +0 -293
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b02e373adcce6e8800e2f1634ed284150dcc3f3505b5d68574474e2bba73927f
|
4
|
+
data.tar.gz: 84eebc2aa1ae92e22425eb14da4d2f6c847263089d921f240bd529555f436ff5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cd570ac39d8258139610d79084b6019481124c5207b872eda4162e0383c0ecdea23e029a88df8264b132608e4e80dc32acb64b5dd2a57d58f093fe516c263a0
|
7
|
+
data.tar.gz: 5ae2934a5116d89a3b4dd367d7603c5ac03aed6a3bbecbdd842a37c6bfe287477a22b091db6aa6cb3e71f83e5b0935b8a30f9020099d60caff5bbac6e45d9c60
|
data/CHANGELOG.md
CHANGED
@@ -2,19 +2,33 @@
|
|
2
2
|
|
3
3
|
## [Unreleased](https://github.com/rpush/rpush/tree/HEAD)
|
4
4
|
|
5
|
+
[Full Changelog](https://github.com/rpush/rpush/compare/v9.1.0...HEAD)
|
6
|
+
|
7
|
+
## [v9.1.0](https://github.com/rpush/rpush/tree/v9.1.0) (2024-09-24)
|
8
|
+
|
5
9
|
**Merged pull requests:**
|
6
10
|
|
7
|
-
*
|
8
|
-
*
|
9
|
-
|
11
|
+
* Add support for FSM iOS badges [\#704](https://github.com/rpush/rpush/pull/704) ([WoutDev](https://github.com/WoutDev))
|
12
|
+
* Support for Rails 7.1 [\#675](https://github.com/rpush/rpush/pull/675) ([benlangfeld](https://github.com/benlangfeld))
|
13
|
+
* Enable running tests on sqlite3 [\#705](https://github.com/rpush/rpush/pull/705) ([benlangfeld](https://github.com/benlangfeld))
|
14
|
+
|
15
|
+
[Full Changelog](https://github.com/rpush/rpush/compare/v9.0.0...v9.1.0)
|
16
|
+
|
17
|
+
## [v9.0.0](https://github.com/rpush/rpush/tree/v9.0.0) (2024-09-09)
|
18
|
+
|
19
|
+
**Merged pull requests:**
|
20
|
+
|
21
|
+
* Support for Ruby 3.2 & 3.3 [\#679](https://github.com/rpush/rpush/pull/679) ([benlangfeld](https://github.com/benlangfeld))
|
10
22
|
|
11
23
|
**Breaking:**
|
12
24
|
|
13
|
-
*
|
25
|
+
* Removed legacy APNSv1 implementation (Apple binary protocol) since this was shut down in 2021. [\#680](https://github.com/rpush/rpush/pull/680) ([benlangfeld](https://github.com/benlangfeld))
|
26
|
+
* Removed legacy GCM implementation since this was shut down by Google in August 2024 and replaced by FCM (supported in RPush 8.0.0) [\#688](https://github.com/rpush/rpush/pull/688) ([benlangfeld](https://github.com/benlangfeld))
|
27
|
+
* Drop support for Ruby 2.x [\#672](https://github.com/rpush/rpush/pull/672) ([benlangfeld](https://github.com/benlangfeld))
|
14
28
|
|
15
|
-
[Full Changelog](https://github.com/rpush/rpush/compare/v8.0.0...
|
29
|
+
[Full Changelog](https://github.com/rpush/rpush/compare/v8.0.0...v9.0.0)
|
16
30
|
|
17
|
-
## [
|
31
|
+
## [v8.0.0](https://github.com/rpush/rpush/tree/v8.0.0) (2024-09-06)
|
18
32
|
|
19
33
|
**Merged pull requests:**
|
20
34
|
|
data/README.md
CHANGED
@@ -57,10 +57,9 @@ There is a choice of two modes (and one legacy mode) using certificates or using
|
|
57
57
|
|
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
|
-
* `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
60
|
Apple have [announced](https://developer.apple.com/news/?id=c88acm2b) that this is not supported after March 31, 2021.
|
62
61
|
|
63
|
-
If this is your first time using the APNs, you will need to generate either SSL certificates (for
|
62
|
+
If this is your first time using the APNs, you will need to generate either SSL certificates (for standard 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
63
|
|
65
64
|
##### Apnsp8
|
66
65
|
|
@@ -83,7 +82,7 @@ n = Rpush::Apnsp8::Notification.new
|
|
83
82
|
n.app = Rpush::Apnsp8::App.find_by_name("ios_app")
|
84
83
|
n.device_token = "..." # hex string
|
85
84
|
n.alert = "hi mom!"
|
86
|
-
# n.alert = { title: "push title", subtitle: "more to say", body: "hi mom!" }
|
85
|
+
# n.alert = { title: "push title", subtitle: "more to say", body: "hi mom!" }
|
87
86
|
n.data = { foo: :bar }
|
88
87
|
n.save!
|
89
88
|
```
|
@@ -108,7 +107,7 @@ n = Rpush::Apns2::Notification.new
|
|
108
107
|
n.app = Rpush::Apns2::App.find_by_name("ios_app")
|
109
108
|
n.device_token = "..." # hex string
|
110
109
|
n.alert = "hi mom!"
|
111
|
-
# n.alert = { title: "push title", subtitle: "more to say", body: "hi mom!" }
|
110
|
+
# n.alert = { title: "push title", subtitle: "more to say", body: "hi mom!" }
|
112
111
|
n.data = {
|
113
112
|
headers: { 'apns-topic': "BUNDLE ID" }, # the bundle id of the app, like com.example.appname. Not necessary if set on the app (see above)
|
114
113
|
foo: :bar
|
@@ -118,48 +117,24 @@ n.save!
|
|
118
117
|
|
119
118
|
You should also implement the [ssl_certificate_will_expire](https://github.com/rpush/rpush/wiki/Reflection-API) reflection to monitor when your certificate is due to expire.
|
120
119
|
|
121
|
-
##### Apns (legacy protocol)
|
122
|
-
|
123
|
-
```ruby
|
124
|
-
app = Rpush::Apns::App.new
|
125
|
-
app.name = "ios_app"
|
126
|
-
app.certificate = File.read("/path/to/sandbox.pem")
|
127
|
-
app.environment = "development" # APNs environment.
|
128
|
-
app.password = "certificate password"
|
129
|
-
app.connections = 1
|
130
|
-
app.save!
|
131
|
-
```
|
132
|
-
|
133
|
-
```ruby
|
134
|
-
n = Rpush::Apns::Notification.new
|
135
|
-
n.app = Rpush::Apns::App.find_by_name("ios_app")
|
136
|
-
n.device_token = "..." # hex string
|
137
|
-
n.alert = "hi mom!"
|
138
|
-
# n.alert = { title: "push title", subtitle: "more to say", body: "hi mom!" }
|
139
|
-
n.data = { foo: :bar }
|
140
|
-
n.save!
|
141
|
-
```
|
142
|
-
|
143
120
|
##### Safari Push Notifications
|
144
121
|
|
145
122
|
Using one of the notifications methods above, the `url_args` attribute is available for Safari Push Notifications.
|
146
123
|
|
147
124
|
##### Environment
|
148
125
|
|
149
|
-
The app `environment` for any Apns* option is "development" for XCode installs, and "production" for app store and TestFlight. Note that
|
126
|
+
The app `environment` for any Apns* option is "development" for XCode installs, and "production" for app store and TestFlight. Note that you can now use one (production + sandbox) certificate (you don't need a separate "sandbox" or development certificate), but if you do generate a development/sandbox certificate it can only be used for "development". With Apnsp8 tokens, you can target either "development" or "production" environments.
|
150
127
|
|
151
128
|
#### Firebase Cloud Messaging
|
152
129
|
|
153
|
-
##### Firebase Cloud Messaging API (V1)
|
154
|
-
|
155
130
|
You will need two params to make use of FCM via Rpush.
|
156
131
|
- `firebase_project_id` - The `Project ID` in your Firebase Project Settings
|
157
132
|
- `json_key` - The JSON key file for a service account with the `Firebase Admin SDK Administrator Service Agent` role.
|
158
133
|
|
159
|
-
Create service account in the google cloud account attached to your firebase account:
|
160
|
-
https://console.cloud.google.com/iam-admin/serviceaccounts
|
161
|
-
Make sure it has Role `Firebase Admin SDK Administrator Service Agent`
|
162
|
-
Add + Download the json key for the service account.
|
134
|
+
Create service account in the google cloud account attached to your firebase account:
|
135
|
+
https://console.cloud.google.com/iam-admin/serviceaccounts
|
136
|
+
Make sure it has Role `Firebase Admin SDK Administrator Service Agent`
|
137
|
+
Add + Download the json key for the service account.
|
163
138
|
|
164
139
|
Once you have those two params, you can create an FCM app and send notifications.
|
165
140
|
|
@@ -180,37 +155,6 @@ n.data = {}.transform_values(&:to_s) # All values going in here have to be strin
|
|
180
155
|
n.save!
|
181
156
|
```
|
182
157
|
|
183
|
-
##### Cloud Messaging API (Legacy)
|
184
|
-
|
185
|
-
**Note:** Deprecated on 2023/6/20 and scheduled to be disabled on 2024/6/20.
|
186
|
-
|
187
|
-
FCM and GCM are – as of writing – compatible with each other. See also [this comment](https://github.com/rpush/rpush/issues/284#issuecomment-228330206) for further references.
|
188
|
-
|
189
|
-
Please refer to the Firebase Console on where to find your `auth_key` (probably called _Server Key_ there). To verify you have the right key, use tools like [Postman](https://www.getpostman.com/), [HTTPie](https://httpie.org/), `curl` or similar before reporting a new issue. See also [this comment](https://github.com/rpush/rpush/issues/346#issuecomment-289218776).
|
190
|
-
|
191
|
-
```ruby
|
192
|
-
app = Rpush::Gcm::App.new
|
193
|
-
app.name = "android_app"
|
194
|
-
app.auth_key = "..."
|
195
|
-
app.connections = 1
|
196
|
-
app.save!
|
197
|
-
```
|
198
|
-
|
199
|
-
```ruby
|
200
|
-
n = Rpush::Gcm::Notification.new
|
201
|
-
n.app = Rpush::Gcm::App.find_by_name("android_app")
|
202
|
-
n.registration_ids = ["..."]
|
203
|
-
n.data = { message: "hi mom!" }
|
204
|
-
n.priority = 'high' # Optional, can be either 'normal' or 'high'
|
205
|
-
n.content_available = true # Optional
|
206
|
-
# Optional notification payload. See the reference below for more keys you can use!
|
207
|
-
n.notification = { body: 'great match!',
|
208
|
-
title: 'Portugal vs. Denmark',
|
209
|
-
icon: 'myicon'
|
210
|
-
}
|
211
|
-
n.save!
|
212
|
-
```
|
213
|
-
|
214
158
|
FCM also requires you to respond to [Canonical IDs](https://github.com/rpush/rpush/wiki/Canonical-IDs).
|
215
159
|
|
216
160
|
Check the [FCM reference](https://firebase.google.com/docs/cloud-messaging/http-server-ref#notification-payload-support) for what keys you can use and are available to you. **Note:** Not all are yet implemented in Rpush.
|
@@ -411,7 +355,6 @@ Rpush will deliver all pending notifications and then exit.
|
|
411
355
|
|
412
356
|
```ruby
|
413
357
|
Rpush.push
|
414
|
-
Rpush.apns_feedback
|
415
358
|
```
|
416
359
|
|
417
360
|
See [Push API](https://github.com/rpush/rpush/wiki/Push-API) for more details.
|
@@ -30,9 +30,6 @@ Rpush.configure do |config|
|
|
30
30
|
# If the logger goes to stdout, you can disable foreground logging to avoid duplication.
|
31
31
|
# config.foreground_logging = false
|
32
32
|
|
33
|
-
# config.apns.feedback_receiver.enabled = true
|
34
|
-
# config.apns.feedback_receiver.frequency = 60
|
35
|
-
|
36
33
|
end
|
37
34
|
|
38
35
|
Rpush.reflect do |on|
|
@@ -76,10 +73,6 @@ Rpush.reflect do |on|
|
|
76
73
|
# on.notification_id_will_retry do |app, notification_id, retry_after|
|
77
74
|
# end
|
78
75
|
|
79
|
-
# Called when a TCP connection is lost and will be reconnected.
|
80
|
-
# on.tcp_connection_lost do |app, error|
|
81
|
-
# end
|
82
|
-
|
83
76
|
# Called for each recipient which successfully receives a notification. This
|
84
77
|
# can occur more than once for the same notification when there are multiple
|
85
78
|
# recipients.
|
@@ -88,7 +81,7 @@ Rpush.reflect do |on|
|
|
88
81
|
|
89
82
|
# Called for each recipient which fails to receive a notification. This
|
90
83
|
# can occur more than once for the same notification when there are multiple
|
91
|
-
# recipients. (do not handle invalid
|
84
|
+
# recipients. (do not handle invalid device tokens here)
|
92
85
|
# on.fcm_failed_to_recipient do |notification, error|
|
93
86
|
# end
|
94
87
|
|
@@ -100,23 +93,23 @@ Rpush.reflect do |on|
|
|
100
93
|
# Called for each recipient which successfully receives a notification. This
|
101
94
|
# can occur more than once for the same notification when there are multiple
|
102
95
|
# recipients.
|
103
|
-
# on.
|
96
|
+
# on.fcm_delivered_to_recipient do |notification, device_token|
|
104
97
|
# end
|
105
98
|
|
106
99
|
# Called for each recipient which fails to receive a notification. This
|
107
100
|
# can occur more than once for the same notification when there are multiple
|
108
|
-
# recipients. (do not handle invalid
|
109
|
-
# on.
|
101
|
+
# recipients. (do not handle invalid device tokens here)
|
102
|
+
# on.fcm_failed_to_recipient do |notification, error, device_token|
|
110
103
|
# end
|
111
104
|
|
112
|
-
# Called when the
|
105
|
+
# Called when the FCM returns a canonical device token.
|
113
106
|
# You will need to replace old_id with canonical_id in your records.
|
114
|
-
# on.
|
107
|
+
# on.fcm_canonical_id do |old_id, canonical_id|
|
115
108
|
# end
|
116
109
|
|
117
|
-
# Called when the
|
118
|
-
# You will need to delete the
|
119
|
-
# on.
|
110
|
+
# Called when the FCM returns a failure that indicates an invalid device token.
|
111
|
+
# You will need to delete the device_token from your records.
|
112
|
+
# on.fcm_invalid_device_token do |app, error, device_token|
|
120
113
|
# end
|
121
114
|
|
122
115
|
# Called when an SSL certificate will expire within 1 month.
|
@@ -25,10 +25,6 @@ require 'rpush/client/active_model/fcm/notification_keys_in_allowed_list_validat
|
|
25
25
|
require 'rpush/client/active_model/fcm/app'
|
26
26
|
require 'rpush/client/active_model/fcm/notification'
|
27
27
|
|
28
|
-
require 'rpush/client/active_model/gcm/expiry_collapse_key_mutual_inclusion_validator'
|
29
|
-
require 'rpush/client/active_model/gcm/app'
|
30
|
-
require 'rpush/client/active_model/gcm/notification'
|
31
|
-
|
32
28
|
require 'rpush/client/active_model/wpns/app'
|
33
29
|
require 'rpush/client/active_model/wpns/notification'
|
34
30
|
|
@@ -19,9 +19,6 @@ require 'rpush/client/active_record/apnsp8/app'
|
|
19
19
|
require 'rpush/client/active_record/fcm/notification'
|
20
20
|
require 'rpush/client/active_record/fcm/app'
|
21
21
|
|
22
|
-
require 'rpush/client/active_record/gcm/notification'
|
23
|
-
require 'rpush/client/active_record/gcm/app'
|
24
|
-
|
25
22
|
require 'rpush/client/active_record/wpns/notification'
|
26
23
|
require 'rpush/client/active_record/wpns/app'
|
27
24
|
|
data/lib/rpush/client/redis.rb
CHANGED
@@ -30,9 +30,6 @@ require 'rpush/client/redis/apnsp8/notification'
|
|
30
30
|
require 'rpush/client/redis/fcm/app'
|
31
31
|
require 'rpush/client/redis/fcm/notification'
|
32
32
|
|
33
|
-
require 'rpush/client/redis/gcm/app'
|
34
|
-
require 'rpush/client/redis/gcm/notification'
|
35
|
-
|
36
33
|
require 'rpush/client/redis/adm/app'
|
37
34
|
require 'rpush/client/redis/adm/notification'
|
38
35
|
|
data/lib/rpush/configuration.rb
CHANGED
@@ -16,27 +16,12 @@ module Rpush
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
CURRENT_ATTRS = [:push_poll, :embedded, :pid_file, :batch_size, :push, :client, :logger, :log_file, :foreground, :foreground_logging, :log_level, :plugin
|
19
|
+
CURRENT_ATTRS = [:push_poll, :embedded, :pid_file, :batch_size, :push, :client, :logger, :log_file, :foreground, :foreground_logging, :log_level, :plugin]
|
20
20
|
DEPRECATED_ATTRS = []
|
21
21
|
CONFIG_ATTRS = CURRENT_ATTRS + DEPRECATED_ATTRS
|
22
22
|
|
23
23
|
class ConfigurationError < StandardError; end
|
24
24
|
|
25
|
-
class ApnsFeedbackReceiverConfiguration < Struct.new(:frequency, :enabled) # rubocop:disable Style/StructInheritance
|
26
|
-
def initialize
|
27
|
-
super
|
28
|
-
self.enabled = true
|
29
|
-
self.frequency = 60
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
class ApnsConfiguration < Struct.new(:feedback_receiver) # rubocop:disable Style/StructInheritance
|
34
|
-
def initialize
|
35
|
-
super
|
36
|
-
self.feedback_receiver = ApnsFeedbackReceiverConfiguration.new
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
25
|
class Configuration < Struct.new(*CONFIG_ATTRS) # rubocop:disable Style/StructInheritance
|
41
26
|
include Deprecatable
|
42
27
|
|
@@ -55,8 +40,6 @@ module Rpush
|
|
55
40
|
self.foreground = false
|
56
41
|
self.foreground_logging = true
|
57
42
|
|
58
|
-
self.apns = ApnsConfiguration.new
|
59
|
-
|
60
43
|
# Internal options.
|
61
44
|
self.embedded = false
|
62
45
|
self.push = false
|
@@ -106,7 +89,7 @@ module Rpush
|
|
106
89
|
client_module = Rpush::Client.const_get(client.to_s.camelize)
|
107
90
|
Rpush.send(:include, client_module) unless Rpush.ancestors.include?(client_module)
|
108
91
|
|
109
|
-
[:Apns, :Fcm, :
|
92
|
+
[:Apns, :Fcm, :Wpns, :Wns, :Adm, :Pushy, :Webpush].each do |service|
|
110
93
|
Rpush.const_set(service, client_module.const_get(service)) unless Rpush.const_defined?(service)
|
111
94
|
end
|
112
95
|
|
@@ -3,8 +3,6 @@ module Rpush
|
|
3
3
|
module ServiceConfigMethods
|
4
4
|
DISPATCHERS = {
|
5
5
|
http: Rpush::Daemon::Dispatcher::Http,
|
6
|
-
tcp: Rpush::Daemon::Dispatcher::Tcp,
|
7
|
-
apns_tcp: Rpush::Daemon::Dispatcher::ApnsTcp,
|
8
6
|
apns_http2: Rpush::Daemon::Dispatcher::ApnsHttp2,
|
9
7
|
apnsp8_http2: Rpush::Daemon::Dispatcher::Apnsp8Http2
|
10
8
|
}
|
@@ -138,26 +138,14 @@ module Rpush
|
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
141
|
-
def create_apns_feedback(failed_at, device_token, app)
|
142
|
-
with_database_reconnect_and_retry do
|
143
|
-
Rpush::Client::ActiveRecord::Apns::Feedback.create!(failed_at: failed_at,
|
144
|
-
device_token: device_token, app_id: app.id)
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
141
|
def create_fcm_notification(attrs, data, app)
|
149
142
|
notification = Rpush::Client::ActiveRecord::Fcm::Notification.new
|
150
143
|
create_fcm_like_notification(notification, attrs, data, app)
|
151
144
|
end
|
152
145
|
|
153
|
-
def create_gcm_notification(attrs, data, registration_ids, deliver_after, app)
|
154
|
-
notification = Rpush::Client::ActiveRecord::Gcm::Notification.new
|
155
|
-
create_gcm_like_notification(notification, attrs, data, registration_ids, deliver_after, app)
|
156
|
-
end
|
157
|
-
|
158
146
|
def create_adm_notification(attrs, data, registration_ids, deliver_after, app)
|
159
147
|
notification = Rpush::Client::ActiveRecord::Adm::Notification.new
|
160
|
-
|
148
|
+
create_adm_like_notification(notification, attrs, data, registration_ids, deliver_after, app)
|
161
149
|
end
|
162
150
|
|
163
151
|
def update_app(app)
|
@@ -209,7 +197,7 @@ module Rpush
|
|
209
197
|
end
|
210
198
|
end
|
211
199
|
|
212
|
-
def
|
200
|
+
def create_adm_like_notification(notification, attrs, data, registration_ids, deliver_after, app) # rubocop:disable Metrics/ParameterLists
|
213
201
|
with_database_reconnect_and_retry do
|
214
202
|
notification.assign_attributes(attrs)
|
215
203
|
notification.data = data
|
@@ -4,8 +4,8 @@ module Rpush
|
|
4
4
|
class Interface
|
5
5
|
PUBLIC_METHODS = [:deliverable_notifications, :mark_retryable,
|
6
6
|
:mark_batch_retryable, :mark_delivered, :mark_batch_delivered,
|
7
|
-
:mark_failed, :mark_batch_failed,
|
8
|
-
:create_fcm_notification, :
|
7
|
+
:mark_failed, :mark_batch_failed,
|
8
|
+
:create_fcm_notification, :create_adm_notification,
|
9
9
|
:update_app, :update_notification, :release_connection,
|
10
10
|
:all_apps, :app, :mark_ids_failed, :mark_ids_retryable,
|
11
11
|
:reopen_log, :pending_delivery_count, :translate_integer_notification_id]
|
@@ -88,23 +88,14 @@ module Rpush
|
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
|
-
def create_apns_feedback(failed_at, device_token, app)
|
92
|
-
Rpush::Client::Redis::Apns::Feedback.create!(failed_at: failed_at, device_token: device_token, app_id: app.id)
|
93
|
-
end
|
94
|
-
|
95
91
|
def create_fcm_notification(attrs, data, app)
|
96
92
|
notification = Rpush::Client::Redis::Fcm::Notification.new
|
97
93
|
create_fcm_like_notification(notification, attrs, data, app)
|
98
94
|
end
|
99
95
|
|
100
|
-
def create_gcm_notification(attrs, data, registration_ids, deliver_after, app)
|
101
|
-
notification = Rpush::Client::Redis::Gcm::Notification.new
|
102
|
-
create_gcm_like_notification(notification, attrs, data, registration_ids, deliver_after, app)
|
103
|
-
end
|
104
|
-
|
105
96
|
def create_adm_notification(attrs, data, registration_ids, deliver_after, app)
|
106
97
|
notification = Rpush::Client::Redis::Adm::Notification.new
|
107
|
-
|
98
|
+
create_adm_like_notification(notification, attrs, data, registration_ids, deliver_after, app)
|
108
99
|
end
|
109
100
|
|
110
101
|
def update_app(app)
|
@@ -151,7 +142,7 @@ module Rpush
|
|
151
142
|
notification
|
152
143
|
end
|
153
144
|
|
154
|
-
def
|
145
|
+
def create_adm_like_notification(notification, attrs, data, registration_ids, deliver_after, app) # rubocop:disable Metrics/ParameterLists
|
155
146
|
notification.assign_attributes(attrs)
|
156
147
|
notification.data = data
|
157
148
|
notification.registration_ids = registration_ids
|
data/lib/rpush/daemon.rb
CHANGED
@@ -19,11 +19,8 @@ require 'rpush/daemon/batch'
|
|
19
19
|
require 'rpush/daemon/queue_payload'
|
20
20
|
require 'rpush/daemon/synchronizer'
|
21
21
|
require 'rpush/daemon/app_runner'
|
22
|
-
require 'rpush/daemon/tcp_connection'
|
23
22
|
require 'rpush/daemon/dispatcher_loop'
|
24
23
|
require 'rpush/daemon/dispatcher/http'
|
25
|
-
require 'rpush/daemon/dispatcher/tcp'
|
26
|
-
require 'rpush/daemon/dispatcher/apns_tcp'
|
27
24
|
require 'rpush/daemon/dispatcher/apns_http2'
|
28
25
|
require 'rpush/daemon/dispatcher/apnsp8_http2'
|
29
26
|
require 'rpush/daemon/service_config_methods'
|
@@ -38,10 +35,6 @@ require 'rpush/daemon/rpc/client'
|
|
38
35
|
|
39
36
|
require 'rpush/daemon/store/interface'
|
40
37
|
|
41
|
-
require 'rpush/daemon/apns/delivery'
|
42
|
-
require 'rpush/daemon/apns/feedback_receiver'
|
43
|
-
require 'rpush/daemon/apns'
|
44
|
-
|
45
38
|
require 'rpush/daemon/apns2/delivery'
|
46
39
|
require 'rpush/daemon/apns2'
|
47
40
|
|
@@ -53,9 +46,6 @@ require 'rpush/daemon/fcm/delivery'
|
|
53
46
|
require 'rpush/daemon/fcm'
|
54
47
|
require 'rpush/daemon/google_credential_cache'
|
55
48
|
|
56
|
-
require 'rpush/daemon/gcm/delivery'
|
57
|
-
require 'rpush/daemon/gcm'
|
58
|
-
|
59
49
|
require 'rpush/daemon/wpns/delivery'
|
60
50
|
require 'rpush/daemon/wpns'
|
61
51
|
|
@@ -5,10 +5,9 @@ module Rpush
|
|
5
5
|
REFLECTIONS = [
|
6
6
|
:apns_feedback, :notification_enqueued, :notification_delivered,
|
7
7
|
:notification_failed, :notification_will_retry,
|
8
|
-
:gcm_delivered_to_recipient, :gcm_failed_to_recipient, :gcm_canonical_id, :gcm_invalid_registration_id,
|
9
8
|
:fcm_delivered_to_recipient, :fcm_failed_to_recipient, :fcm_canonical_id, :fcm_invalid_device_token,
|
10
9
|
:error, :adm_canonical_id, :adm_failed_to_recipient, :wns_invalid_channel,
|
11
|
-
:
|
10
|
+
:ssl_certificate_will_expire, :ssl_certificate_revoked,
|
12
11
|
:notification_id_will_retry, :notification_id_failed
|
13
12
|
]
|
14
13
|
|
data/lib/rpush/version.rb
CHANGED
data/lib/rpush.rb
CHANGED
data/spec/functional/cli_spec.rb
CHANGED
@@ -2,31 +2,57 @@ require 'functional_spec_helper'
|
|
2
2
|
|
3
3
|
describe Rpush::CLI do
|
4
4
|
def create_app
|
5
|
-
app = Rpush::
|
5
|
+
app = Rpush::Apns2::App.new
|
6
6
|
app.certificate = TEST_CERT
|
7
7
|
app.name = 'test'
|
8
|
-
app.environment = '
|
8
|
+
app.environment = 'development'
|
9
|
+
app.bundle_id = 'com.example.app'
|
9
10
|
app.save!
|
10
11
|
app
|
11
12
|
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
let(:fake_client) {
|
15
|
+
double(
|
16
|
+
prepare_request: fake_http2_request,
|
17
|
+
close: 'ok',
|
18
|
+
call_async: 'ok',
|
19
|
+
join: 'ok',
|
20
|
+
on: 'ok'
|
21
|
+
)
|
22
|
+
}
|
23
|
+
let(:fake_http2_request) { double }
|
24
|
+
let(:fake_http_resp_headers) {
|
25
|
+
{
|
26
|
+
":status" => "200",
|
27
|
+
"apns-id"=>"C6D65840-5E3F-785A-4D91-B97D305C12F6"
|
28
|
+
}
|
29
|
+
}
|
30
|
+
let(:fake_http_resp_body) { '' }
|
17
31
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
Rpush.embed
|
32
|
+
before do
|
33
|
+
create_app
|
34
|
+
Rpush.config.push_poll = 0.5
|
22
35
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
36
|
+
allow(NetHttp2::Client).
|
37
|
+
to receive(:new).and_return(fake_client)
|
38
|
+
allow(fake_http2_request).
|
39
|
+
to receive(:on).with(:headers).
|
40
|
+
and_yield(fake_http_resp_headers)
|
41
|
+
allow(fake_http2_request).
|
42
|
+
to receive(:on).with(:body_chunk).
|
43
|
+
and_yield(fake_http_resp_body)
|
44
|
+
allow(fake_http2_request).
|
45
|
+
to receive(:on).with(:close).
|
46
|
+
and_yield
|
47
|
+
|
48
|
+
Rpush.embed
|
49
|
+
end
|
27
50
|
|
28
|
-
|
51
|
+
after do
|
52
|
+
timeout { Rpush.shutdown }
|
53
|
+
end
|
29
54
|
|
55
|
+
describe 'status' do
|
30
56
|
it 'prints the status' do
|
31
57
|
expect(subject).to receive(:configure_rpush) { true }
|
32
58
|
expect(subject).to receive(:puts).with(/app_runners:/)
|