rpush_extended 3.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +365 -0
- data/LICENSE +7 -0
- data/README.md +393 -0
- data/bin/rpush +4 -0
- data/lib/generators/rpush_config_generator.rb +7 -0
- data/lib/generators/rpush_migration_generator.rb +66 -0
- data/lib/generators/templates/add_adm.rb +23 -0
- data/lib/generators/templates/add_alert_is_json_to_rapns_notifications.rb +9 -0
- data/lib/generators/templates/add_app_to_rapns.rb +11 -0
- data/lib/generators/templates/add_fail_after_to_rpush_notifications.rb +9 -0
- data/lib/generators/templates/add_gcm.rb +117 -0
- data/lib/generators/templates/add_rpush.rb +402 -0
- data/lib/generators/templates/add_wpns.rb +16 -0
- data/lib/generators/templates/create_rapns_apps.rb +16 -0
- data/lib/generators/templates/create_rapns_feedback.rb +25 -0
- data/lib/generators/templates/create_rapns_notifications.rb +36 -0
- data/lib/generators/templates/rename_rapns_to_rpush.rb +87 -0
- data/lib/generators/templates/rpush.rb +135 -0
- data/lib/generators/templates/rpush_2_0_0_updates.rb +79 -0
- data/lib/generators/templates/rpush_2_1_0_updates.rb +11 -0
- data/lib/generators/templates/rpush_2_6_0_updates.rb +10 -0
- data/lib/generators/templates/rpush_2_7_0_updates.rb +12 -0
- data/lib/generators/templates/rpush_3_0_0_updates.rb +11 -0
- data/lib/generators/templates/rpush_3_0_1_updates.rb +13 -0
- data/lib/generators/templates/rpush_3_1_0_add_pushy.rb +9 -0
- data/lib/generators/templates/rpush_3_1_1_updates.rb +15 -0
- data/lib/generators/templates/rpush_3_2_0_add_apns_p8.rb +15 -0
- data/lib/generators/templates/rpush_3_2_4_updates.rb +9 -0
- data/lib/generators/templates/rpush_3_3_0_updates.rb +9 -0
- data/lib/generators/templates/rpush_3_3_1_updates.rb +11 -0
- data/lib/rpush/apns_feedback.rb +17 -0
- data/lib/rpush/cli.rb +213 -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 +104 -0
- data/lib/rpush/client/active_model/apns2/app.rb +15 -0
- data/lib/rpush/client/active_model/apns2/notification.rb +9 -0
- data/lib/rpush/client/active_model/apnsp8/app.rb +23 -0
- data/lib/rpush/client/active_model/apnsp8/notification.rb +9 -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 +59 -0
- data/lib/rpush/client/active_model/notification.rb +22 -0
- data/lib/rpush/client/active_model/payload_data_size_validator.rb +13 -0
- data/lib/rpush/client/active_model/pushy/app.rb +20 -0
- data/lib/rpush/client/active_model/pushy/notification.rb +31 -0
- data/lib/rpush/client/active_model/pushy/time_to_live_validator.rb +14 -0
- data/lib/rpush/client/active_model/registration_ids_count_validator.rb +13 -0
- data/lib/rpush/client/active_model/wns/app.rb +23 -0
- data/lib/rpush/client/active_model/wns/notification.rb +32 -0
- data/lib/rpush/client/active_model/wpns/app.rb +13 -0
- data/lib/rpush/client/active_model/wpns/notification.rb +28 -0
- data/lib/rpush/client/active_model.rb +34 -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 +18 -0
- data/lib/rpush/client/active_record/apns/notification.rb +40 -0
- data/lib/rpush/client/active_record/apns2/app.rb +11 -0
- data/lib/rpush/client/active_record/apns2/notification.rb +10 -0
- data/lib/rpush/client/active_record/apnsp8/app.rb +11 -0
- data/lib/rpush/client/active_record/apnsp8/notification.rb +10 -0
- data/lib/rpush/client/active_record/app.rb +13 -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 +42 -0
- data/lib/rpush/client/active_record/pushy/app.rb +11 -0
- data/lib/rpush/client/active_record/pushy/notification.rb +11 -0
- data/lib/rpush/client/active_record/wns/app.rb +11 -0
- data/lib/rpush/client/active_record/wns/badge_notification.rb +15 -0
- data/lib/rpush/client/active_record/wns/notification.rb +11 -0
- data/lib/rpush/client/active_record/wns/raw_notification.rb +13 -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/active_record.rb +33 -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/apns2/app.rb +11 -0
- data/lib/rpush/client/redis/apns2/notification.rb +11 -0
- data/lib/rpush/client/redis/apnsp8/app.rb +11 -0
- data/lib/rpush/client/redis/apnsp8/notification.rb +11 -0
- data/lib/rpush/client/redis/app.rb +29 -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 +74 -0
- data/lib/rpush/client/redis/pushy/app.rb +16 -0
- data/lib/rpush/client/redis/pushy/notification.rb +18 -0
- data/lib/rpush/client/redis/wns/app.rb +14 -0
- data/lib/rpush/client/redis/wns/badge_notification.rb +15 -0
- data/lib/rpush/client/redis/wns/notification.rb +11 -0
- data/lib/rpush/client/redis/wns/raw_notification.rb +11 -0
- data/lib/rpush/client/redis/wpns/app.rb +11 -0
- data/lib/rpush/client/redis/wpns/notification.rb +11 -0
- data/lib/rpush/client/redis.rb +56 -0
- data/lib/rpush/configuration.rb +115 -0
- data/lib/rpush/daemon/adm/delivery.rb +226 -0
- data/lib/rpush/daemon/adm.rb +9 -0
- data/lib/rpush/daemon/apns/delivery.rb +43 -0
- data/lib/rpush/daemon/apns/feedback_receiver.rb +90 -0
- data/lib/rpush/daemon/apns.rb +17 -0
- data/lib/rpush/daemon/apns2/delivery.rb +127 -0
- data/lib/rpush/daemon/apns2.rb +10 -0
- data/lib/rpush/daemon/apnsp8/delivery.rb +166 -0
- data/lib/rpush/daemon/apnsp8/token.rb +43 -0
- data/lib/rpush/daemon/apnsp8.rb +10 -0
- data/lib/rpush/daemon/app_runner.rb +190 -0
- data/lib/rpush/daemon/batch.rb +138 -0
- data/lib/rpush/daemon/constants.rb +59 -0
- data/lib/rpush/daemon/delivery.rb +46 -0
- data/lib/rpush/daemon/delivery_error.rb +27 -0
- data/lib/rpush/daemon/dispatcher/apns_http2.rb +51 -0
- data/lib/rpush/daemon/dispatcher/apns_tcp.rb +152 -0
- data/lib/rpush/daemon/dispatcher/apnsp8_http2.rb +33 -0
- data/lib/rpush/daemon/dispatcher/http.rb +21 -0
- data/lib/rpush/daemon/dispatcher/tcp.rb +22 -0
- data/lib/rpush/daemon/dispatcher_loop.rb +73 -0
- data/lib/rpush/daemon/errors.rb +18 -0
- data/lib/rpush/daemon/feeder.rb +69 -0
- data/lib/rpush/daemon/gcm/delivery.rb +241 -0
- data/lib/rpush/daemon/gcm.rb +9 -0
- data/lib/rpush/daemon/interruptible_sleep.rb +24 -0
- data/lib/rpush/daemon/loggable.rb +33 -0
- data/lib/rpush/daemon/proc_title.rb +17 -0
- data/lib/rpush/daemon/pushy/delivery.rb +90 -0
- data/lib/rpush/daemon/pushy.rb +9 -0
- data/lib/rpush/daemon/queue_payload.rb +12 -0
- data/lib/rpush/daemon/retry_header_parser.rb +23 -0
- data/lib/rpush/daemon/retryable_error.rb +22 -0
- data/lib/rpush/daemon/ring_buffer.rb +16 -0
- data/lib/rpush/daemon/rpc/client.rb +27 -0
- data/lib/rpush/daemon/rpc/server.rb +82 -0
- data/lib/rpush/daemon/rpc.rb +9 -0
- data/lib/rpush/daemon/service_config_methods.rb +51 -0
- data/lib/rpush/daemon/signal_handler.rb +75 -0
- data/lib/rpush/daemon/store/active_record/reconnectable.rb +80 -0
- data/lib/rpush/daemon/store/active_record.rb +214 -0
- data/lib/rpush/daemon/store/interface.rb +20 -0
- data/lib/rpush/daemon/store/redis.rb +166 -0
- data/lib/rpush/daemon/string_helpers.rb +15 -0
- data/lib/rpush/daemon/synchronizer.rb +62 -0
- data/lib/rpush/daemon/tcp_connection.rb +190 -0
- data/lib/rpush/daemon/wns/badge_request.rb +32 -0
- data/lib/rpush/daemon/wns/delivery.rb +178 -0
- data/lib/rpush/daemon/wns/post_request.rb +33 -0
- data/lib/rpush/daemon/wns/raw_request.rb +22 -0
- data/lib/rpush/daemon/wns/toast_request.rb +54 -0
- data/lib/rpush/daemon/wns.rb +9 -0
- data/lib/rpush/daemon/wpns/delivery.rb +132 -0
- data/lib/rpush/daemon/wpns.rb +9 -0
- data/lib/rpush/daemon.rb +179 -0
- data/lib/rpush/deprecatable.rb +24 -0
- data/lib/rpush/deprecation.rb +26 -0
- data/lib/rpush/embed.rb +41 -0
- data/lib/rpush/logger.rb +92 -0
- data/lib/rpush/multi_json_helper.rb +16 -0
- data/lib/rpush/plugin.rb +44 -0
- data/lib/rpush/push.rb +11 -0
- data/lib/rpush/reflectable.rb +13 -0
- data/lib/rpush/reflection_collection.rb +44 -0
- data/lib/rpush/reflection_public_methods.rb +11 -0
- data/lib/rpush/version.rb +14 -0
- data/lib/rpush.rb +43 -0
- data/lib/tasks/quality.rake +35 -0
- data/lib/tasks/test.rake +69 -0
- data/spec/.rubocop.yml +4 -0
- data/spec/functional/adm_spec.rb +50 -0
- data/spec/functional/apns2_spec.rb +232 -0
- data/spec/functional/apns_spec.rb +162 -0
- data/spec/functional/cli_spec.rb +36 -0
- data/spec/functional/embed_spec.rb +49 -0
- data/spec/functional/gcm_spec.rb +46 -0
- data/spec/functional/new_app_spec.rb +44 -0
- data/spec/functional/pushy_spec.rb +22 -0
- data/spec/functional/retry_spec.rb +42 -0
- data/spec/functional/synchronization_spec.rb +97 -0
- data/spec/functional/wpns_spec.rb +71 -0
- data/spec/functional_spec_helper.rb +32 -0
- data/spec/spec_helper.rb +69 -0
- data/spec/support/active_record_setup.rb +73 -0
- data/spec/support/cert_with_password.pem +90 -0
- data/spec/support/cert_without_password.pem +59 -0
- data/spec/support/config/database.yml +44 -0
- data/spec/support/simplecov_helper.rb +24 -0
- data/spec/support/simplecov_quality_formatter.rb +12 -0
- data/spec/tmp/.gitkeep +0 -0
- data/spec/unit/apns_feedback_spec.rb +28 -0
- data/spec/unit/client/active_record/adm/app_spec.rb +58 -0
- data/spec/unit/client/active_record/adm/notification_spec.rb +43 -0
- 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 +324 -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/client/active_record/gcm/notification_spec.rb +67 -0
- data/spec/unit/client/active_record/notification_spec.rb +21 -0
- data/spec/unit/client/active_record/pushy/app_spec.rb +17 -0
- data/spec/unit/client/active_record/pushy/notification_spec.rb +65 -0
- data/spec/unit/client/active_record/wns/badge_notification_spec.rb +15 -0
- data/spec/unit/client/active_record/wns/raw_notification_spec.rb +26 -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 +46 -0
- data/spec/unit/daemon/adm/delivery_spec.rb +253 -0
- data/spec/unit/daemon/apns/certificate_expired_error_spec.rb +11 -0
- data/spec/unit/daemon/apns/delivery_spec.rb +108 -0
- data/spec/unit/daemon/apns/feedback_receiver_spec.rb +119 -0
- data/spec/unit/daemon/app_runner_spec.rb +188 -0
- data/spec/unit/daemon/batch_spec.rb +169 -0
- data/spec/unit/daemon/delivery_error_spec.rb +13 -0
- data/spec/unit/daemon/delivery_spec.rb +51 -0
- data/spec/unit/daemon/dispatcher/http_spec.rb +34 -0
- data/spec/unit/daemon/dispatcher/tcp_spec.rb +32 -0
- data/spec/unit/daemon/dispatcher_loop_spec.rb +53 -0
- data/spec/unit/daemon/feeder_spec.rb +96 -0
- data/spec/unit/daemon/gcm/delivery_spec.rb +387 -0
- data/spec/unit/daemon/proc_title_spec.rb +11 -0
- data/spec/unit/daemon/pushy/delivery_spec.rb +159 -0
- data/spec/unit/daemon/retryable_error_spec.rb +14 -0
- data/spec/unit/daemon/service_config_methods_spec.rb +36 -0
- data/spec/unit/daemon/signal_handler_spec.rb +99 -0
- data/spec/unit/daemon/store/active_record/reconnectable_spec.rb +165 -0
- data/spec/unit/daemon/store/active_record_spec.rb +357 -0
- data/spec/unit/daemon/store/redis_spec.rb +365 -0
- data/spec/unit/daemon/tcp_connection_spec.rb +292 -0
- data/spec/unit/daemon/wns/delivery_spec.rb +176 -0
- data/spec/unit/daemon/wns/post_request_spec.rb +117 -0
- data/spec/unit/daemon/wpns/delivery_spec.rb +167 -0
- data/spec/unit/daemon_spec.rb +138 -0
- data/spec/unit/deprecatable_spec.rb +32 -0
- data/spec/unit/deprecation_spec.rb +15 -0
- data/spec/unit/embed_spec.rb +47 -0
- data/spec/unit/logger_spec.rb +127 -0
- data/spec/unit/notification_shared.rb +53 -0
- data/spec/unit/plugin_spec.rb +36 -0
- data/spec/unit/push_spec.rb +34 -0
- data/spec/unit/reflectable_spec.rb +27 -0
- data/spec/unit/reflection_collection_spec.rb +26 -0
- data/spec/unit/rpush_spec.rb +8 -0
- data/spec/unit_spec_helper.rb +26 -0
- metadata +709 -0
@@ -0,0 +1,40 @@
|
|
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
|
+
def alert=(alert)
|
10
|
+
if alert.is_a?(Hash)
|
11
|
+
write_attribute(:alert, multi_json_dump(alert))
|
12
|
+
self.alert_is_json = true if has_attribute?(:alert_is_json)
|
13
|
+
else
|
14
|
+
write_attribute(:alert, alert)
|
15
|
+
self.alert_is_json = false if has_attribute?(:alert_is_json)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def alert
|
20
|
+
string_or_json = read_attribute(:alert)
|
21
|
+
|
22
|
+
if has_attribute?(:alert_is_json)
|
23
|
+
if alert_is_json?
|
24
|
+
multi_json_load(string_or_json)
|
25
|
+
else
|
26
|
+
string_or_json
|
27
|
+
end
|
28
|
+
else
|
29
|
+
begin
|
30
|
+
multi_json_load(string_or_json)
|
31
|
+
rescue StandardError
|
32
|
+
string_or_json
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Rpush
|
2
|
+
module Client
|
3
|
+
module ActiveRecord
|
4
|
+
class App < ::ActiveRecord::Base
|
5
|
+
self.table_name = 'rpush_apps'
|
6
|
+
|
7
|
+
has_many :notifications, class_name: 'Rpush::Client::ActiveRecord::Notification', dependent: :destroy
|
8
|
+
|
9
|
+
validates :name, presence: true, uniqueness: { scope: [:type, :environment] }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,42 @@
|
|
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
|
+
serialize :registration_ids
|
11
|
+
serialize :url_args
|
12
|
+
|
13
|
+
belongs_to :app, class_name: 'Rpush::Client::ActiveRecord::App'
|
14
|
+
|
15
|
+
def data=(attrs)
|
16
|
+
return unless attrs
|
17
|
+
fail ArgumentError, 'must be a Hash' unless attrs.is_a?(Hash)
|
18
|
+
write_attribute(:data, multi_json_dump(attrs.merge(data || {})))
|
19
|
+
end
|
20
|
+
|
21
|
+
def notification=(attrs)
|
22
|
+
return unless attrs
|
23
|
+
fail ArgumentError, 'must be a Hash' unless attrs.is_a?(Hash)
|
24
|
+
write_attribute(:notification, 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
|
+
|
36
|
+
def notification
|
37
|
+
multi_json_load(read_attribute(:notification)) if read_attribute(:notification)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Rpush
|
2
|
+
module Client
|
3
|
+
module ActiveRecord
|
4
|
+
module Wns
|
5
|
+
class BadgeNotification < Rpush::Client::ActiveRecord::Notification
|
6
|
+
include Rpush::Client::ActiveModel::Wns::Notification
|
7
|
+
|
8
|
+
def skip_data_validation?
|
9
|
+
true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Rpush
|
2
|
+
module Client
|
3
|
+
module ActiveRecord
|
4
|
+
module Wns
|
5
|
+
class RawNotification < Rpush::Client::ActiveRecord::Notification
|
6
|
+
validates_with Rpush::Client::ActiveModel::PayloadDataSizeValidator,
|
7
|
+
limit: 5120
|
8
|
+
include Rpush::Client::ActiveModel::Wns::Notification
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,33 @@
|
|
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/apns2/notification'
|
13
|
+
require 'rpush/client/active_record/apns2/app'
|
14
|
+
|
15
|
+
require 'rpush/client/active_record/apnsp8/notification'
|
16
|
+
require 'rpush/client/active_record/apnsp8/app'
|
17
|
+
|
18
|
+
require 'rpush/client/active_record/gcm/notification'
|
19
|
+
require 'rpush/client/active_record/gcm/app'
|
20
|
+
|
21
|
+
require 'rpush/client/active_record/wpns/notification'
|
22
|
+
require 'rpush/client/active_record/wpns/app'
|
23
|
+
|
24
|
+
require 'rpush/client/active_record/wns/notification'
|
25
|
+
require 'rpush/client/active_record/wns/raw_notification'
|
26
|
+
require 'rpush/client/active_record/wns/badge_notification'
|
27
|
+
require 'rpush/client/active_record/wns/app'
|
28
|
+
|
29
|
+
require 'rpush/client/active_record/adm/notification'
|
30
|
+
require 'rpush/client/active_record/adm/app'
|
31
|
+
|
32
|
+
require 'rpush/client/active_record/pushy/notification'
|
33
|
+
require 'rpush/client/active_record/pushy/app'
|
@@ -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
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Rpush
|
2
|
+
module Client
|
3
|
+
module Redis
|
4
|
+
module Apns
|
5
|
+
class Feedback
|
6
|
+
include Modis::Model
|
7
|
+
|
8
|
+
attribute :app_id, :integer
|
9
|
+
attribute :device_token, :string
|
10
|
+
attribute :failed_at, :timestamp
|
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,29 @@
|
|
1
|
+
module Rpush
|
2
|
+
module Client
|
3
|
+
module Redis
|
4
|
+
class App
|
5
|
+
include Modis::Model
|
6
|
+
self.namespace = 'apps'
|
7
|
+
|
8
|
+
attribute :name, :string
|
9
|
+
attribute :environment, :string
|
10
|
+
attribute :certificate, :string
|
11
|
+
attribute :password, :string
|
12
|
+
attribute :connections, :integer, default: 1
|
13
|
+
attribute :auth_key, :string
|
14
|
+
attribute :client_id, :string
|
15
|
+
attribute :client_secret, :string
|
16
|
+
attribute :api_key, :string
|
17
|
+
attribute :apn_key, :string
|
18
|
+
attribute :apn_key_id, :string
|
19
|
+
attribute :team_id, :string
|
20
|
+
attribute :bundle_id, :string
|
21
|
+
|
22
|
+
index :name
|
23
|
+
|
24
|
+
validates :name, presence: true
|
25
|
+
validates_numericality_of :connections, greater_than: 0, only_integer: true
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module Rpush
|
2
|
+
module Client
|
3
|
+
module Redis
|
4
|
+
class Notification
|
5
|
+
include Rpush::MultiJsonHelper
|
6
|
+
include Modis::Model
|
7
|
+
include Rpush::Client::ActiveModel::Notification
|
8
|
+
|
9
|
+
after_create :register_notification
|
10
|
+
|
11
|
+
self.namespace = 'notifications'
|
12
|
+
|
13
|
+
def self.absolute_pending_namespace
|
14
|
+
"#{absolute_namespace}:pending"
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.absolute_retryable_namespace
|
18
|
+
"#{absolute_namespace}:retryable"
|
19
|
+
end
|
20
|
+
|
21
|
+
attribute :badge, :integer
|
22
|
+
attribute :device_token, :string
|
23
|
+
attribute :sound, :string, default: 'default'
|
24
|
+
attribute :alert, [:string, :hash], strict: false
|
25
|
+
attribute :data, :hash
|
26
|
+
attribute :expiry, :integer, default: 1.day.to_i
|
27
|
+
attribute :delivered, :boolean
|
28
|
+
attribute :delivered_at, :timestamp
|
29
|
+
attribute :failed, :boolean
|
30
|
+
attribute :failed_at, :timestamp
|
31
|
+
attribute :fail_after, :timestamp
|
32
|
+
attribute :retries, :integer, default: 0
|
33
|
+
attribute :error_code, :integer
|
34
|
+
attribute :error_description, :string
|
35
|
+
attribute :deliver_after, :timestamp
|
36
|
+
attribute :alert_is_json, :boolean
|
37
|
+
attribute :app_id, :integer
|
38
|
+
attribute :collapse_key, :string
|
39
|
+
attribute :delay_while_idle, :boolean
|
40
|
+
attribute :registration_ids, :array
|
41
|
+
attribute :uri, :string
|
42
|
+
attribute :priority, :integer
|
43
|
+
attribute :url_args, :array
|
44
|
+
attribute :category, :string
|
45
|
+
attribute :content_available, :boolean, default: false
|
46
|
+
attribute :mutable_content, :boolean, default: false
|
47
|
+
attribute :notification, :hash
|
48
|
+
attribute :thread_id, :string
|
49
|
+
|
50
|
+
def app
|
51
|
+
return nil unless app_id
|
52
|
+
@app ||= Rpush::Client::Redis::App.find(app_id)
|
53
|
+
end
|
54
|
+
|
55
|
+
def app=(app)
|
56
|
+
@app = app
|
57
|
+
if app
|
58
|
+
self.app_id = app.id
|
59
|
+
else
|
60
|
+
self.app_id = nil
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def register_notification
|
67
|
+
Modis.with_connection do |redis|
|
68
|
+
redis.zadd(self.class.absolute_pending_namespace, id, id)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Rpush
|
2
|
+
module Client
|
3
|
+
module Redis
|
4
|
+
module Pushy
|
5
|
+
class Notification < Rpush::Client::Redis::Notification
|
6
|
+
include Rpush::Client::ActiveModel::Pushy::Notification
|
7
|
+
|
8
|
+
attribute :external_device_id, :string
|
9
|
+
|
10
|
+
def time_to_live=(value)
|
11
|
+
self.expiry = value
|
12
|
+
super
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Rpush
|
2
|
+
module Client
|
3
|
+
module Redis
|
4
|
+
module Wns
|
5
|
+
class App < Rpush::Client::Redis::App
|
6
|
+
include Rpush::Client::ActiveModel::Wns::App
|
7
|
+
|
8
|
+
attribute :access_token, :string
|
9
|
+
attribute :access_token_expiration, :timestamp
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Rpush
|
2
|
+
module Client
|
3
|
+
module Redis
|
4
|
+
module Wns
|
5
|
+
class BadgeNotification < Rpush::Client::Redis::Notification
|
6
|
+
include Rpush::Client::ActiveModel::Wns::Notification
|
7
|
+
|
8
|
+
def skip_data_validation?
|
9
|
+
true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|