rpush 1.0.0 → 2.0.0.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/README.md +12 -14
- data/bin/rpush +11 -2
- data/lib/generators/rpush_generator.rb +2 -0
- data/lib/generators/templates/add_adm.rb +5 -5
- data/lib/generators/templates/add_alert_is_json_to_rapns_notifications.rb +1 -1
- 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 +32 -32
- data/lib/generators/templates/add_rpush.rb +67 -67
- data/lib/generators/templates/add_wpns.rb +2 -2
- data/lib/generators/templates/create_rapns_apps.rb +5 -5
- data/lib/generators/templates/create_rapns_feedback.rb +2 -2
- data/lib/generators/templates/create_rapns_notifications.rb +15 -15
- data/lib/generators/templates/rpush.rb +10 -7
- data/lib/generators/templates/rpush_2_0_0_updates.rb +23 -0
- data/lib/rpush.rb +4 -28
- data/lib/rpush/client/active_model.rb +21 -0
- data/lib/rpush/client/active_model/adm/app.rb +23 -0
- data/lib/rpush/client/active_model/adm/data_validator.rb +14 -0
- data/lib/rpush/client/active_model/adm/notification.rb +28 -0
- data/lib/rpush/client/active_model/apns/app.rb +37 -0
- data/lib/rpush/client/active_model/apns/binary_notification_validator.rb +16 -0
- data/lib/rpush/client/active_model/apns/device_token_format_validator.rb +14 -0
- data/lib/rpush/client/active_model/apns/notification.rb +90 -0
- data/lib/rpush/client/active_model/gcm/app.rb +19 -0
- data/lib/rpush/client/active_model/gcm/expiry_collapse_key_mutual_inclusion_validator.rb +14 -0
- data/lib/rpush/client/active_model/gcm/notification.rb +31 -0
- data/lib/rpush/client/active_model/notification.rb +26 -0
- data/lib/rpush/client/active_model/payload_data_size_validator.rb +13 -0
- data/lib/rpush/client/active_model/registration_ids_count_validator.rb +13 -0
- data/lib/rpush/client/active_model/wpns/app.rb +13 -0
- data/lib/rpush/client/active_model/wpns/notification.rb +17 -0
- data/lib/rpush/client/active_record.rb +19 -0
- data/lib/rpush/client/active_record/adm/app.rb +11 -0
- data/lib/rpush/client/active_record/adm/notification.rb +11 -0
- data/lib/rpush/client/active_record/apns/app.rb +11 -0
- data/lib/rpush/client/active_record/apns/feedback.rb +20 -0
- data/lib/rpush/client/active_record/apns/notification.rb +46 -0
- data/lib/rpush/client/active_record/app.rb +17 -0
- data/lib/rpush/client/active_record/gcm/app.rb +11 -0
- data/lib/rpush/client/active_record/gcm/notification.rb +11 -0
- data/lib/rpush/client/active_record/notification.rb +38 -0
- data/lib/rpush/client/active_record/wpns/app.rb +11 -0
- data/lib/rpush/client/active_record/wpns/notification.rb +11 -0
- data/lib/rpush/client/redis.rb +35 -0
- data/lib/rpush/client/redis/adm/app.rb +14 -0
- data/lib/rpush/client/redis/adm/notification.rb +11 -0
- data/lib/rpush/client/redis/apns/app.rb +11 -0
- data/lib/rpush/client/redis/apns/feedback.rb +20 -0
- data/lib/rpush/client/redis/apns/notification.rb +11 -0
- data/lib/rpush/client/redis/app.rb +22 -0
- data/lib/rpush/client/redis/gcm/app.rb +11 -0
- data/lib/rpush/client/redis/gcm/notification.rb +11 -0
- data/lib/rpush/client/redis/notification.rb +68 -0
- data/lib/rpush/client/redis/wpns/app.rb +11 -0
- data/lib/rpush/client/redis/wpns/notification.rb +11 -0
- data/lib/rpush/configuration.rb +27 -6
- data/lib/rpush/daemon.rb +36 -56
- data/lib/rpush/daemon/adm/delivery.rb +50 -52
- data/lib/rpush/daemon/apns.rb +6 -5
- data/lib/rpush/daemon/apns/delivery.rb +20 -44
- data/lib/rpush/daemon/apns/feedback_receiver.rb +11 -8
- data/lib/rpush/daemon/app_runner.rb +67 -60
- data/lib/rpush/daemon/batch.rb +54 -40
- data/lib/rpush/daemon/delivery.rb +13 -3
- data/lib/rpush/daemon/delivery_error.rb +10 -2
- data/lib/rpush/daemon/dispatcher/apns_tcp.rb +106 -0
- data/lib/rpush/daemon/dispatcher/http.rb +3 -3
- data/lib/rpush/daemon/dispatcher/tcp.rb +3 -3
- data/lib/rpush/daemon/dispatcher_loop.rb +15 -6
- data/lib/rpush/daemon/errors.rb +18 -0
- data/lib/rpush/daemon/feeder.rb +28 -39
- data/lib/rpush/daemon/gcm/delivery.rb +19 -20
- data/lib/rpush/daemon/interruptible_sleep.rb +26 -45
- data/lib/rpush/daemon/loggable.rb +2 -4
- data/lib/rpush/daemon/proc_title.rb +16 -0
- data/lib/rpush/daemon/queue_payload.rb +12 -0
- data/lib/rpush/daemon/reflectable.rb +3 -5
- data/lib/rpush/daemon/retry_header_parser.rb +6 -6
- data/lib/rpush/daemon/ring_buffer.rb +16 -0
- data/lib/rpush/daemon/service_config_methods.rb +23 -7
- data/lib/rpush/daemon/signal_handler.rb +51 -0
- data/lib/rpush/daemon/store/active_record.rb +71 -38
- data/lib/rpush/daemon/store/active_record/reconnectable.rb +15 -15
- data/lib/rpush/daemon/store/interface.rb +19 -0
- data/lib/rpush/daemon/store/redis.rb +149 -0
- data/lib/rpush/daemon/tcp_connection.rb +6 -11
- data/lib/rpush/daemon/wpns/delivery.rb +21 -30
- data/lib/rpush/deprecatable.rb +4 -3
- data/lib/rpush/deprecation.rb +7 -10
- data/lib/rpush/embed.rb +7 -2
- data/lib/rpush/logger.rb +11 -15
- data/lib/rpush/push.rb +0 -1
- data/lib/rpush/reflection.rb +6 -12
- data/lib/rpush/version.rb +1 -1
- data/lib/tasks/quality.rake +34 -0
- data/spec/.rubocop.yml +4 -0
- data/spec/functional/adm_spec.rb +3 -6
- data/spec/functional/apns_spec.rb +118 -24
- data/spec/functional/embed_spec.rb +22 -20
- data/spec/functional/gcm_spec.rb +4 -7
- data/spec/functional/new_app_spec.rb +61 -0
- data/spec/functional/retry_spec.rb +46 -0
- data/spec/functional/wpns_spec.rb +3 -6
- data/spec/functional_spec_helper.rb +26 -0
- data/spec/integration/rpush_spec.rb +13 -0
- data/spec/integration/support/gcm_success_response.json +1 -0
- data/spec/spec_helper.rb +60 -0
- data/spec/support/active_record_setup.rb +48 -0
- data/{config → spec/support/config}/database.yml +0 -0
- data/spec/support/install.sh +43 -7
- data/spec/support/simplecov_helper.rb +9 -5
- data/spec/support/simplecov_quality_formatter.rb +10 -6
- data/spec/unit/apns_feedback_spec.rb +3 -3
- data/spec/unit/{adm → client/active_record/adm}/app_spec.rb +3 -3
- data/spec/unit/{adm → client/active_record/adm}/notification_spec.rb +5 -7
- data/spec/unit/client/active_record/apns/app_spec.rb +29 -0
- data/spec/unit/client/active_record/apns/feedback_spec.rb +9 -0
- data/spec/unit/client/active_record/apns/notification_spec.rb +231 -0
- data/spec/unit/client/active_record/app_spec.rb +30 -0
- data/spec/unit/client/active_record/gcm/app_spec.rb +4 -0
- data/spec/unit/{gcm → client/active_record/gcm}/notification_spec.rb +5 -7
- data/spec/unit/client/active_record/notification_spec.rb +15 -0
- data/spec/unit/client/active_record/wpns/app_spec.rb +4 -0
- data/spec/unit/client/active_record/wpns/notification_spec.rb +21 -0
- data/spec/unit/configuration_spec.rb +12 -5
- data/spec/unit/daemon/adm/delivery_spec.rb +57 -54
- data/spec/unit/daemon/apns/certificate_expired_error_spec.rb +3 -3
- data/spec/unit/daemon/apns/delivery_spec.rb +90 -83
- data/spec/unit/daemon/apns/feedback_receiver_spec.rb +24 -17
- data/spec/unit/daemon/app_runner_spec.rb +66 -123
- data/spec/unit/daemon/batch_spec.rb +52 -115
- data/spec/unit/daemon/delivery_spec.rb +15 -1
- data/spec/unit/daemon/dispatcher/http_spec.rb +3 -2
- data/spec/unit/daemon/dispatcher/tcp_spec.rb +10 -9
- data/spec/unit/daemon/dispatcher_loop_spec.rb +7 -12
- data/spec/unit/daemon/feeder_spec.rb +40 -39
- data/spec/unit/daemon/gcm/delivery_spec.rb +108 -89
- data/spec/unit/daemon/reflectable_spec.rb +2 -2
- data/spec/unit/daemon/retryable_error_spec.rb +1 -1
- data/spec/unit/daemon/service_config_methods_spec.rb +6 -3
- data/spec/unit/daemon/signal_handler_spec.rb +72 -0
- data/spec/unit/daemon/store/active_record/reconnectable_spec.rb +9 -9
- data/spec/unit/daemon/store/active_record_spec.rb +38 -47
- data/spec/unit/daemon/tcp_connection_spec.rb +22 -34
- data/spec/unit/daemon/too_many_requests_error_spec.rb +1 -1
- data/spec/unit/daemon/wpns/delivery_spec.rb +61 -50
- data/spec/unit/daemon_spec.rb +46 -81
- data/spec/unit/embed_spec.rb +4 -2
- data/spec/unit/logger_spec.rb +30 -40
- data/spec/unit/notification_shared.rb +9 -79
- data/spec/unit/push_spec.rb +3 -8
- data/spec/unit/reflection_spec.rb +25 -25
- data/spec/unit/rpush_spec.rb +1 -2
- data/spec/unit_spec_helper.rb +33 -88
- metadata +119 -67
- data/lib/rpush/TODO +0 -3
- data/lib/rpush/adm/app.rb +0 -15
- data/lib/rpush/adm/data_validator.rb +0 -11
- data/lib/rpush/adm/notification.rb +0 -29
- data/lib/rpush/apns/app.rb +0 -29
- data/lib/rpush/apns/binary_notification_validator.rb +0 -12
- data/lib/rpush/apns/device_token_format_validator.rb +0 -12
- data/lib/rpush/apns/feedback.rb +0 -16
- data/lib/rpush/apns/notification.rb +0 -84
- data/lib/rpush/app.rb +0 -18
- data/lib/rpush/daemon/apns/certificate_expired_error.rb +0 -20
- data/lib/rpush/daemon/apns/disconnection_error.rb +0 -20
- data/lib/rpush/gcm/app.rb +0 -11
- data/lib/rpush/gcm/expiry_collapse_key_mutual_inclusion_validator.rb +0 -11
- data/lib/rpush/gcm/notification.rb +0 -30
- data/lib/rpush/notification.rb +0 -69
- data/lib/rpush/notifier.rb +0 -52
- data/lib/rpush/payload_data_size_validator.rb +0 -10
- data/lib/rpush/railtie.rb +0 -11
- data/lib/rpush/registration_ids_count_validator.rb +0 -10
- data/lib/rpush/wpns/app.rb +0 -9
- data/lib/rpush/wpns/notification.rb +0 -26
- data/lib/tasks/cane.rake +0 -18
- data/lib/tasks/rpush.rake +0 -16
- data/spec/unit/apns/app_spec.rb +0 -29
- data/spec/unit/apns/feedback_spec.rb +0 -9
- data/spec/unit/apns/notification_spec.rb +0 -208
- data/spec/unit/app_spec.rb +0 -30
- data/spec/unit/daemon/apns/disconnection_error_spec.rb +0 -18
- data/spec/unit/daemon/interruptible_sleep_spec.rb +0 -68
- data/spec/unit/gcm/app_spec.rb +0 -4
- data/spec/unit/notification_spec.rb +0 -15
- data/spec/unit/notifier_spec.rb +0 -49
- data/spec/unit/wpns/app_spec.rb +0 -4
- data/spec/unit/wpns/notification_spec.rb +0 -30
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Rpush
|
|
2
|
+
module Client
|
|
3
|
+
module ActiveModel
|
|
4
|
+
module Gcm
|
|
5
|
+
module App
|
|
6
|
+
def self.included(base)
|
|
7
|
+
base.instance_eval do
|
|
8
|
+
validates :auth_key, presence: true
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def service_name
|
|
13
|
+
'gcm'
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module Rpush
|
|
2
|
+
module Client
|
|
3
|
+
module ActiveModel
|
|
4
|
+
module Gcm
|
|
5
|
+
class ExpiryCollapseKeyMutualInclusionValidator < ::ActiveModel::Validator
|
|
6
|
+
def validate(record)
|
|
7
|
+
return unless record.collapse_key && !record.expiry
|
|
8
|
+
record.errors[:expiry] << 'must be set when using a collapse_key'
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module Rpush
|
|
2
|
+
module Client
|
|
3
|
+
module ActiveModel
|
|
4
|
+
module Gcm
|
|
5
|
+
module Notification
|
|
6
|
+
def self.included(base)
|
|
7
|
+
base.instance_eval do
|
|
8
|
+
validates :registration_ids, presence: true
|
|
9
|
+
|
|
10
|
+
validates_with Rpush::Client::ActiveModel::PayloadDataSizeValidator, limit: 4096
|
|
11
|
+
validates_with Rpush::Client::ActiveModel::RegistrationIdsCountValidator, limit: 1000
|
|
12
|
+
|
|
13
|
+
validates_with Rpush::Client::ActiveModel::Gcm::ExpiryCollapseKeyMutualInclusionValidator
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def as_json
|
|
18
|
+
json = {
|
|
19
|
+
'registration_ids' => registration_ids,
|
|
20
|
+
'delay_while_idle' => delay_while_idle,
|
|
21
|
+
'data' => data
|
|
22
|
+
}
|
|
23
|
+
json['collapse_key'] = collapse_key if collapse_key
|
|
24
|
+
json['time_to_live'] = expiry if expiry
|
|
25
|
+
json
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module Rpush
|
|
2
|
+
module Client
|
|
3
|
+
module ActiveModel
|
|
4
|
+
module Notification
|
|
5
|
+
def self.included(base)
|
|
6
|
+
base.instance_eval do
|
|
7
|
+
validates :expiry, numericality: true, allow_nil: true
|
|
8
|
+
validates :app_id, presence: true
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def payload
|
|
13
|
+
multi_json_dump(as_json)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def payload_size
|
|
17
|
+
payload.bytesize
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def payload_data_size
|
|
21
|
+
multi_json_dump(as_json['data']).bytesize
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module Rpush
|
|
2
|
+
module Client
|
|
3
|
+
module ActiveModel
|
|
4
|
+
class PayloadDataSizeValidator < ::ActiveModel::Validator
|
|
5
|
+
def validate(record)
|
|
6
|
+
limit = options[:limit] || 1024
|
|
7
|
+
return unless record.data && record.payload_data_size > limit
|
|
8
|
+
record.errors[:base] << "Notification payload data cannot be larger than #{limit} bytes."
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module Rpush
|
|
2
|
+
module Client
|
|
3
|
+
module ActiveModel
|
|
4
|
+
class RegistrationIdsCountValidator < ::ActiveModel::Validator
|
|
5
|
+
def validate(record)
|
|
6
|
+
limit = options[:limit] || 100
|
|
7
|
+
return unless record.registration_ids && record.registration_ids.size > limit
|
|
8
|
+
record.errors[:base] << "Number of registration_ids cannot be larger than #{limit}."
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Rpush
|
|
2
|
+
module Client
|
|
3
|
+
module ActiveModel
|
|
4
|
+
module Wpns
|
|
5
|
+
module Notification
|
|
6
|
+
def self.included(base)
|
|
7
|
+
base.instance_eval do
|
|
8
|
+
validates :uri, presence: true
|
|
9
|
+
validates :uri, format: { with: %r{https?://[\S]+} }
|
|
10
|
+
validates :alert, presence: true
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'active_record'
|
|
2
|
+
|
|
3
|
+
require 'rpush/client/active_model'
|
|
4
|
+
|
|
5
|
+
require 'rpush/client/active_record/notification'
|
|
6
|
+
require 'rpush/client/active_record/app'
|
|
7
|
+
|
|
8
|
+
require 'rpush/client/active_record/apns/notification'
|
|
9
|
+
require 'rpush/client/active_record/apns/feedback'
|
|
10
|
+
require 'rpush/client/active_record/apns/app'
|
|
11
|
+
|
|
12
|
+
require 'rpush/client/active_record/gcm/notification'
|
|
13
|
+
require 'rpush/client/active_record/gcm/app'
|
|
14
|
+
|
|
15
|
+
require 'rpush/client/active_record/wpns/notification'
|
|
16
|
+
require 'rpush/client/active_record/wpns/app'
|
|
17
|
+
|
|
18
|
+
require 'rpush/client/active_record/adm/notification'
|
|
19
|
+
require 'rpush/client/active_record/adm/app'
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module Rpush
|
|
2
|
+
module Client
|
|
3
|
+
module ActiveRecord
|
|
4
|
+
module Apns
|
|
5
|
+
class Feedback < ::ActiveRecord::Base
|
|
6
|
+
self.table_name = 'rpush_feedback'
|
|
7
|
+
|
|
8
|
+
if Rpush.attr_accessible_available?
|
|
9
|
+
attr_accessible :device_token, :failed_at, :app
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
validates :device_token, presence: true
|
|
13
|
+
validates :failed_at, presence: true
|
|
14
|
+
|
|
15
|
+
validates_with Rpush::Client::ActiveModel::Apns::DeviceTokenFormatValidator
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
module Rpush
|
|
2
|
+
module Client
|
|
3
|
+
module ActiveRecord
|
|
4
|
+
module Apns
|
|
5
|
+
class Notification < Rpush::Client::ActiveRecord::Notification
|
|
6
|
+
include Deprecatable
|
|
7
|
+
include Rpush::Client::ActiveModel::Apns::Notification
|
|
8
|
+
|
|
9
|
+
alias_method :attributes_for_device=, :data=
|
|
10
|
+
alias_method :attributes_for_device, :data
|
|
11
|
+
|
|
12
|
+
deprecated(:attributes_for_device, '2.1.0', 'Use :data instead.')
|
|
13
|
+
deprecated(:attributes_for_device=, '2.1.0', 'Use :data instead.')
|
|
14
|
+
|
|
15
|
+
def alert=(alert)
|
|
16
|
+
if alert.is_a?(Hash)
|
|
17
|
+
write_attribute(:alert, multi_json_dump(alert))
|
|
18
|
+
self.alert_is_json = true if has_attribute?(:alert_is_json)
|
|
19
|
+
else
|
|
20
|
+
write_attribute(:alert, alert)
|
|
21
|
+
self.alert_is_json = false if has_attribute?(:alert_is_json)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def alert
|
|
26
|
+
string_or_json = read_attribute(:alert)
|
|
27
|
+
|
|
28
|
+
if has_attribute?(:alert_is_json)
|
|
29
|
+
if alert_is_json?
|
|
30
|
+
multi_json_load(string_or_json)
|
|
31
|
+
else
|
|
32
|
+
string_or_json
|
|
33
|
+
end
|
|
34
|
+
else
|
|
35
|
+
begin
|
|
36
|
+
multi_json_load(string_or_json)
|
|
37
|
+
rescue StandardError
|
|
38
|
+
string_or_json
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Rpush
|
|
2
|
+
module Client
|
|
3
|
+
module ActiveRecord
|
|
4
|
+
class App < ::ActiveRecord::Base
|
|
5
|
+
self.table_name = 'rpush_apps'
|
|
6
|
+
|
|
7
|
+
if Rpush.attr_accessible_available?
|
|
8
|
+
attr_accessible :name, :environment, :certificate, :password, :connections, :auth_key, :client_id, :client_secret
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
has_many :notifications, class_name: 'Rpush::Client::ActiveRecord::Notification', dependent: :destroy
|
|
12
|
+
|
|
13
|
+
validates :name, presence: true, uniqueness: { scope: [:type, :environment] }
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module Rpush
|
|
2
|
+
module Client
|
|
3
|
+
module ActiveRecord
|
|
4
|
+
class Notification < ::ActiveRecord::Base
|
|
5
|
+
include Rpush::MultiJsonHelper
|
|
6
|
+
include Rpush::Client::ActiveModel::Notification
|
|
7
|
+
|
|
8
|
+
self.table_name = 'rpush_notifications'
|
|
9
|
+
|
|
10
|
+
# TODO: Dump using multi json.
|
|
11
|
+
serialize :registration_ids
|
|
12
|
+
|
|
13
|
+
belongs_to :app, class_name: 'Rpush::Client::ActiveRecord::App'
|
|
14
|
+
|
|
15
|
+
if Rpush.attr_accessible_available?
|
|
16
|
+
attr_accessible :badge, :device_token, :sound, :alert, :data, :expiry, :delivered,
|
|
17
|
+
:delivered_at, :failed, :failed_at, :error_code, :error_description, :deliver_after,
|
|
18
|
+
:alert_is_json, :app, :app_id, :collapse_key, :delay_while_idle, :registration_ids, :uri
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def data=(attrs)
|
|
22
|
+
return unless attrs
|
|
23
|
+
fail ArgumentError, "must be a Hash" unless attrs.is_a?(Hash)
|
|
24
|
+
write_attribute(:data, multi_json_dump(attrs.merge(data || {})))
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def registration_ids=(ids)
|
|
28
|
+
ids = [ids] if ids && !ids.is_a?(Array)
|
|
29
|
+
super
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def data
|
|
33
|
+
multi_json_load(read_attribute(:data)) if read_attribute(:data)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# :nocov:
|
|
2
|
+
begin
|
|
3
|
+
require 'modis'
|
|
4
|
+
rescue LoadError
|
|
5
|
+
puts
|
|
6
|
+
str = "* Please add 'rpush-redis' to your Gemfile to use the Redis client. *"
|
|
7
|
+
puts "*" * str.size
|
|
8
|
+
puts str
|
|
9
|
+
puts "*" * str.size
|
|
10
|
+
puts
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
require 'redis'
|
|
14
|
+
|
|
15
|
+
require 'rpush/client/active_model'
|
|
16
|
+
|
|
17
|
+
require 'rpush/client/redis/app'
|
|
18
|
+
require 'rpush/client/redis/notification'
|
|
19
|
+
|
|
20
|
+
require 'rpush/client/redis/apns/app'
|
|
21
|
+
require 'rpush/client/redis/apns/notification'
|
|
22
|
+
require 'rpush/client/redis/apns/feedback'
|
|
23
|
+
|
|
24
|
+
require 'rpush/client/redis/gcm/app'
|
|
25
|
+
require 'rpush/client/redis/gcm/notification'
|
|
26
|
+
|
|
27
|
+
require 'rpush/client/redis/adm/app'
|
|
28
|
+
require 'rpush/client/redis/adm/notification'
|
|
29
|
+
|
|
30
|
+
require 'rpush/client/redis/wpns/app'
|
|
31
|
+
require 'rpush/client/redis/wpns/notification'
|
|
32
|
+
|
|
33
|
+
Modis.configure do |config|
|
|
34
|
+
config.namespace = :rpush
|
|
35
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module Rpush
|
|
2
|
+
module Client
|
|
3
|
+
module Redis
|
|
4
|
+
module Adm
|
|
5
|
+
class App < Rpush::Client::Redis::App
|
|
6
|
+
include Rpush::Client::ActiveModel::Adm::App
|
|
7
|
+
|
|
8
|
+
attribute :access_token, :string
|
|
9
|
+
attribute :access_token_expiration, :timestamp
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|