actionwebpush 0.1.0
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 +7 -0
- data/.ruby-version +1 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/CONTRIBUTING.md +256 -0
- data/LICENSE.txt +21 -0
- data/README.md +569 -0
- data/Rakefile +17 -0
- data/app/controllers/actionwebpush/subscriptions_controller.rb +60 -0
- data/app/models/actionwebpush/subscription.rb +164 -0
- data/config/routes.rb +5 -0
- data/db/migrate/001_create_action_web_push_subscriptions.rb +17 -0
- data/lib/actionwebpush/analytics.rb +197 -0
- data/lib/actionwebpush/authorization.rb +236 -0
- data/lib/actionwebpush/base.rb +107 -0
- data/lib/actionwebpush/batch_delivery.rb +92 -0
- data/lib/actionwebpush/configuration.rb +91 -0
- data/lib/actionwebpush/delivery_job.rb +52 -0
- data/lib/actionwebpush/delivery_methods/base.rb +19 -0
- data/lib/actionwebpush/delivery_methods/test.rb +36 -0
- data/lib/actionwebpush/delivery_methods/web_push.rb +74 -0
- data/lib/actionwebpush/engine.rb +20 -0
- data/lib/actionwebpush/error_handler.rb +99 -0
- data/lib/actionwebpush/generators/campfire_migration_generator.rb +69 -0
- data/lib/actionwebpush/generators/install_generator.rb +47 -0
- data/lib/actionwebpush/generators/templates/campfire_compatibility.rb +173 -0
- data/lib/actionwebpush/generators/templates/campfire_data_migration.rb +98 -0
- data/lib/actionwebpush/generators/templates/create_action_web_push_subscriptions.rb +17 -0
- data/lib/actionwebpush/generators/templates/initializer.rb +16 -0
- data/lib/actionwebpush/generators/vapid_keys_generator.rb +38 -0
- data/lib/actionwebpush/instrumentation.rb +31 -0
- data/lib/actionwebpush/logging.rb +38 -0
- data/lib/actionwebpush/metrics.rb +67 -0
- data/lib/actionwebpush/notification.rb +97 -0
- data/lib/actionwebpush/pool.rb +167 -0
- data/lib/actionwebpush/railtie.rb +48 -0
- data/lib/actionwebpush/rate_limiter.rb +167 -0
- data/lib/actionwebpush/sentry_integration.rb +104 -0
- data/lib/actionwebpush/status_broadcaster.rb +62 -0
- data/lib/actionwebpush/status_channel.rb +21 -0
- data/lib/actionwebpush/tenant_configuration.rb +106 -0
- data/lib/actionwebpush/test_helper.rb +68 -0
- data/lib/actionwebpush/version.rb +5 -0
- data/lib/actionwebpush.rb +78 -0
- data/sig/actionwebpush.rbs +4 -0
- metadata +212 -0
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActionWebPush
|
4
|
+
module TestHelper
|
5
|
+
def setup_action_web_push
|
6
|
+
ActionWebPush.configure do |config|
|
7
|
+
config.delivery_method = :test
|
8
|
+
config.vapid_public_key = "test_public_key"
|
9
|
+
config.vapid_private_key = "test_private_key"
|
10
|
+
config.vapid_subject = "mailto:test@example.com"
|
11
|
+
end
|
12
|
+
|
13
|
+
clear_action_web_push_deliveries
|
14
|
+
end
|
15
|
+
|
16
|
+
def clear_action_web_push_deliveries
|
17
|
+
ActionWebPush::DeliveryMethods::Test.clear_deliveries!
|
18
|
+
end
|
19
|
+
|
20
|
+
def action_web_push_deliveries
|
21
|
+
ActionWebPush::DeliveryMethods::Test.deliveries
|
22
|
+
end
|
23
|
+
|
24
|
+
def assert_no_push_deliveries
|
25
|
+
assert_equal 0, action_web_push_deliveries.size, "Expected no push notifications, but #{action_web_push_deliveries.size} were sent"
|
26
|
+
end
|
27
|
+
|
28
|
+
def assert_push_delivered_to(subscription, options = {})
|
29
|
+
delivery = action_web_push_deliveries.find do |d|
|
30
|
+
d[:endpoint] == subscription.endpoint &&
|
31
|
+
d[:p256dh_key] == subscription.p256dh_key &&
|
32
|
+
d[:auth_key] == subscription.auth_key
|
33
|
+
end
|
34
|
+
|
35
|
+
assert delivery, "Expected push notification to be delivered to subscription #{subscription.id}, but none was found"
|
36
|
+
|
37
|
+
if options[:title]
|
38
|
+
assert_equal options[:title], delivery[:title], "Expected title '#{options[:title]}' but got '#{delivery[:title]}'"
|
39
|
+
end
|
40
|
+
|
41
|
+
if options[:body]
|
42
|
+
assert_equal options[:body], delivery[:body], "Expected body '#{options[:body]}' but got '#{delivery[:body]}'"
|
43
|
+
end
|
44
|
+
|
45
|
+
delivery
|
46
|
+
end
|
47
|
+
|
48
|
+
def assert_push_deliveries(count)
|
49
|
+
assert_equal count, action_web_push_deliveries.size, "Expected #{count} push notifications, but #{action_web_push_deliveries.size} were sent"
|
50
|
+
end
|
51
|
+
|
52
|
+
def last_push_delivery
|
53
|
+
action_web_push_deliveries.last
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# Include in Minitest
|
59
|
+
if defined?(Minitest::Test)
|
60
|
+
Minitest::Test.include ActionWebPush::TestHelper
|
61
|
+
end
|
62
|
+
|
63
|
+
# Include in RSpec
|
64
|
+
if defined?(RSpec)
|
65
|
+
RSpec.configure do |config|
|
66
|
+
config.include ActionWebPush::TestHelper
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "actionwebpush/version"
|
4
|
+
|
5
|
+
module ActionWebPush
|
6
|
+
class Error < StandardError; end
|
7
|
+
class DeliveryError < Error; end
|
8
|
+
class ExpiredSubscriptionError < Error; end
|
9
|
+
class ConfigurationError < Error; end
|
10
|
+
class RateLimitExceeded < Error; end
|
11
|
+
|
12
|
+
autoload :Configuration, "actionwebpush/configuration"
|
13
|
+
autoload :Notification, "actionwebpush/notification"
|
14
|
+
autoload :Pool, "actionwebpush/pool"
|
15
|
+
autoload :Base, "actionwebpush/base"
|
16
|
+
autoload :DeliveryJob, "actionwebpush/delivery_job"
|
17
|
+
autoload :BatchDelivery, "actionwebpush/batch_delivery"
|
18
|
+
autoload :Metrics, "actionwebpush/metrics"
|
19
|
+
autoload :TestHelper, "actionwebpush/test_helper"
|
20
|
+
autoload :StatusChannel, "actionwebpush/status_channel"
|
21
|
+
autoload :StatusBroadcaster, "actionwebpush/status_broadcaster"
|
22
|
+
autoload :RateLimiter, "actionwebpush/rate_limiter"
|
23
|
+
autoload :TenantConfiguration, "actionwebpush/tenant_configuration"
|
24
|
+
autoload :TenantManager, "actionwebpush/tenant_configuration"
|
25
|
+
autoload :SentryIntegration, "actionwebpush/sentry_integration"
|
26
|
+
autoload :Analytics, "actionwebpush/analytics"
|
27
|
+
autoload :Logging, "actionwebpush/logging"
|
28
|
+
autoload :Instrumentation, "actionwebpush/instrumentation"
|
29
|
+
autoload :ErrorHandler, "actionwebpush/error_handler"
|
30
|
+
autoload :Authorization, "actionwebpush/authorization"
|
31
|
+
|
32
|
+
module DeliveryMethods
|
33
|
+
autoload :Base, "actionwebpush/delivery_methods/base"
|
34
|
+
autoload :WebPush, "actionwebpush/delivery_methods/web_push"
|
35
|
+
autoload :Test, "actionwebpush/delivery_methods/test"
|
36
|
+
|
37
|
+
@delivery_methods = {}
|
38
|
+
|
39
|
+
def self.for(method)
|
40
|
+
case method.to_sym
|
41
|
+
when :test
|
42
|
+
Test.new
|
43
|
+
when :web_push
|
44
|
+
WebPush.new
|
45
|
+
else
|
46
|
+
@delivery_methods[method.to_sym]&.new || raise(ArgumentError, "Unknown delivery method: #{method}")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.register(name, klass)
|
51
|
+
@delivery_methods[name.to_sym] = klass
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
class << self
|
56
|
+
attr_accessor :configuration
|
57
|
+
|
58
|
+
def configure
|
59
|
+
self.configuration ||= Configuration.new
|
60
|
+
yield(configuration) if block_given?
|
61
|
+
end
|
62
|
+
|
63
|
+
def config
|
64
|
+
self.configuration ||= Configuration.new
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
if defined?(Rails)
|
70
|
+
require "actionwebpush/railtie"
|
71
|
+
require "actionwebpush/engine"
|
72
|
+
|
73
|
+
module Generators
|
74
|
+
autoload :InstallGenerator, "actionwebpush/generators/install_generator"
|
75
|
+
autoload :VapidKeysGenerator, "actionwebpush/generators/vapid_keys_generator"
|
76
|
+
autoload :CampfireMigrationGenerator, "actionwebpush/generators/campfire_migration_generator"
|
77
|
+
end
|
78
|
+
end
|
metadata
ADDED
@@ -0,0 +1,212 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: actionwebpush
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Keshav Kk
|
8
|
+
bindir: exe
|
9
|
+
cert_chain: []
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
|
+
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: rails
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '6.0'
|
19
|
+
- - "<"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '9.0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '6.0'
|
29
|
+
- - "<"
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: '9.0'
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: web-push
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - "~>"
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '3.0'
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 3.0.0
|
42
|
+
type: :runtime
|
43
|
+
prerelease: false
|
44
|
+
version_requirements: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '3.0'
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: 3.0.0
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
name: concurrent-ruby
|
54
|
+
requirement: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - "~>"
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '1.1'
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.1.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.1'
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: 1.1.0
|
72
|
+
- !ruby/object:Gem::Dependency
|
73
|
+
name: net-http-persistent
|
74
|
+
requirement: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - "~>"
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '4.0'
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 4.0.0
|
82
|
+
type: :runtime
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '4.0'
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: 4.0.0
|
92
|
+
- !ruby/object:Gem::Dependency
|
93
|
+
name: sqlite3
|
94
|
+
requirement: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - "~>"
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '1.4'
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 1.4.0
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - "~>"
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '1.4'
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: 1.4.0
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: resque
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - "~>"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '2.0'
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: 2.0.0
|
122
|
+
type: :development
|
123
|
+
prerelease: false
|
124
|
+
version_requirements: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - "~>"
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '2.0'
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 2.0.0
|
132
|
+
description: ActionWebPush provides Rails integration for Web Push notifications with
|
133
|
+
ActionMailer-like interface, thread pool management, and subscription handling.
|
134
|
+
email:
|
135
|
+
- keshavkk.musafir@gmail.com
|
136
|
+
executables: []
|
137
|
+
extensions: []
|
138
|
+
extra_rdoc_files: []
|
139
|
+
files:
|
140
|
+
- ".ruby-version"
|
141
|
+
- CODE_OF_CONDUCT.md
|
142
|
+
- CONTRIBUTING.md
|
143
|
+
- LICENSE.txt
|
144
|
+
- README.md
|
145
|
+
- Rakefile
|
146
|
+
- app/controllers/actionwebpush/subscriptions_controller.rb
|
147
|
+
- app/models/actionwebpush/subscription.rb
|
148
|
+
- config/routes.rb
|
149
|
+
- db/migrate/001_create_action_web_push_subscriptions.rb
|
150
|
+
- lib/actionwebpush.rb
|
151
|
+
- lib/actionwebpush/analytics.rb
|
152
|
+
- lib/actionwebpush/authorization.rb
|
153
|
+
- lib/actionwebpush/base.rb
|
154
|
+
- lib/actionwebpush/batch_delivery.rb
|
155
|
+
- lib/actionwebpush/configuration.rb
|
156
|
+
- lib/actionwebpush/delivery_job.rb
|
157
|
+
- lib/actionwebpush/delivery_methods/base.rb
|
158
|
+
- lib/actionwebpush/delivery_methods/test.rb
|
159
|
+
- lib/actionwebpush/delivery_methods/web_push.rb
|
160
|
+
- lib/actionwebpush/engine.rb
|
161
|
+
- lib/actionwebpush/error_handler.rb
|
162
|
+
- lib/actionwebpush/generators/campfire_migration_generator.rb
|
163
|
+
- lib/actionwebpush/generators/install_generator.rb
|
164
|
+
- lib/actionwebpush/generators/templates/campfire_compatibility.rb
|
165
|
+
- lib/actionwebpush/generators/templates/campfire_data_migration.rb
|
166
|
+
- lib/actionwebpush/generators/templates/create_action_web_push_subscriptions.rb
|
167
|
+
- lib/actionwebpush/generators/templates/initializer.rb
|
168
|
+
- lib/actionwebpush/generators/vapid_keys_generator.rb
|
169
|
+
- lib/actionwebpush/instrumentation.rb
|
170
|
+
- lib/actionwebpush/logging.rb
|
171
|
+
- lib/actionwebpush/metrics.rb
|
172
|
+
- lib/actionwebpush/notification.rb
|
173
|
+
- lib/actionwebpush/pool.rb
|
174
|
+
- lib/actionwebpush/railtie.rb
|
175
|
+
- lib/actionwebpush/rate_limiter.rb
|
176
|
+
- lib/actionwebpush/sentry_integration.rb
|
177
|
+
- lib/actionwebpush/status_broadcaster.rb
|
178
|
+
- lib/actionwebpush/status_channel.rb
|
179
|
+
- lib/actionwebpush/tenant_configuration.rb
|
180
|
+
- lib/actionwebpush/test_helper.rb
|
181
|
+
- lib/actionwebpush/version.rb
|
182
|
+
- sig/actionwebpush.rbs
|
183
|
+
homepage: https://github.com/keshav-k3/actionwebpush
|
184
|
+
licenses:
|
185
|
+
- MIT
|
186
|
+
metadata:
|
187
|
+
allowed_push_host: https://rubygems.org
|
188
|
+
homepage_uri: https://github.com/keshav-k3/actionwebpush
|
189
|
+
source_code_uri: https://github.com/keshav-k3/actionwebpush
|
190
|
+
changelog_uri: https://github.com/keshav-k3/actionwebpush/blob/main/CHANGELOG.md
|
191
|
+
bug_tracker_uri: https://github.com/keshav-k3/actionwebpush/issues
|
192
|
+
documentation_uri: https://github.com/keshav-k3/actionwebpush#readme
|
193
|
+
wiki_uri: https://github.com/keshav-k3/actionwebpush/wiki
|
194
|
+
rubygems_mfa_required: 'true'
|
195
|
+
rdoc_options: []
|
196
|
+
require_paths:
|
197
|
+
- lib
|
198
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
199
|
+
requirements:
|
200
|
+
- - ">="
|
201
|
+
- !ruby/object:Gem::Version
|
202
|
+
version: 2.6.0
|
203
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
204
|
+
requirements:
|
205
|
+
- - ">="
|
206
|
+
- !ruby/object:Gem::Version
|
207
|
+
version: '0'
|
208
|
+
requirements: []
|
209
|
+
rubygems_version: 3.6.9
|
210
|
+
specification_version: 4
|
211
|
+
summary: Rails integration for Web Push notifications
|
212
|
+
test_files: []
|