Skip to content

Commit bbef924

Browse files
committed
Replace unmaintained webpush with web-push gem
1 parent 656f632 commit bbef924

4 files changed

Lines changed: 11 additions & 9 deletions

File tree

DEVELOPMENT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,5 +192,5 @@ To test notifications, open the site in Chrome and give permission, and then:
192192

193193
```rb
194194
@subscription = Subscription.last
195-
Webpush.payload_send(endpoint: @subscription.endpoint, message: "tag|title|body", p256dh: @subscription.p256dh, auth: @subscription.auth, vapid: { subject: "mailto:" + ENV.fetch('VAPID_CONTACT_EMAIL'), public_key: ENV.fetch('VAPID_PUBLIC_KEY') , private_key: ENV.fetch('VAPID_PRIVATE_KEY') }, ttl: 60 * 60)
195+
WebPush.payload_send(endpoint: @subscription.endpoint, message: "tag|title|body", p256dh: @subscription.p256dh, auth: @subscription.auth, vapid: { subject: "mailto:" + ENV.fetch('VAPID_CONTACT_EMAIL'), public_key: ENV.fetch('VAPID_PUBLIC_KEY') , private_key: ENV.fetch('VAPID_PRIVATE_KEY') }, ttl: 60 * 60)
196196
```

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ gem 'devise-jwt'
4646

4747
# Push notifications
4848
gem 'serviceworker-rails'
49-
gem 'webpush'
49+
gem 'web-push'
5050

5151
# Email when something breaks
5252
gem 'exception_notification'

Gemfile.lock

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ GEM
184184
guard-compat (~> 1.1)
185185
rspec (>= 2.99.0, < 4.0)
186186
hashdiff (1.0.1)
187-
hkdf (0.3.0)
187+
hkdf (1.0.0)
188188
htmlentities (4.3.4)
189189
i18n (1.12.0)
190190
concurrent-ruby (~> 1.0)
@@ -234,6 +234,7 @@ GEM
234234
notiffany (0.1.3)
235235
nenv (~> 0.1)
236236
shellany (~> 0.0)
237+
openssl (3.1.0)
237238
orm_adapter (0.5.0)
238239
parallel (1.22.1)
239240
parallel_tests (4.2.0)
@@ -411,6 +412,10 @@ GEM
411412
dry-configurable (>= 0.13, < 2)
412413
jwt (~> 2.1)
413414
warden (~> 1.2)
415+
web-push (3.0.0)
416+
hkdf (~> 1.0)
417+
jwt (~> 2.0)
418+
openssl (~> 3.0)
414419
webmock (3.18.1)
415420
addressable (>= 2.8.0)
416421
crack (>= 0.3.2)
@@ -420,9 +425,6 @@ GEM
420425
rack-proxy (>= 0.6.1)
421426
railties (>= 5.2)
422427
semantic_range (>= 2.3.0)
423-
webpush (1.1.0)
424-
hkdf (~> 0.2)
425-
jwt (~> 2.0)
426428
websocket-driver (0.7.5)
427429
websocket-extensions (>= 0.1.0)
428430
websocket-extensions (0.1.5)
@@ -487,9 +489,9 @@ DEPENDENCIES
487489
table_print
488490
terminal-notifier-guard (~> 1.6.1)
489491
timecop
492+
web-push
490493
webmock
491494
webpacker (~> 5.4.3)
492-
webpush
493495

494496
RUBY VERSION
495497
ruby 3.1.2p20

app/models/subscription.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class << self
55
# Send push notifications to everyone
66
def blast(tag, subject, body)
77
Subscription.all.find_each do |s|
8-
Webpush.payload_send(
8+
WebPush.payload_send(
99
endpoint: s.endpoint,
1010
message: "#{tag}|#{subject}|#{body}",
1111
p256dh: s.p256dh,
@@ -17,7 +17,7 @@ def blast(tag, subject, body)
1717
private_key: ENV.fetch('VAPID_PRIVATE_KEY', nil)
1818
}
1919
)
20-
rescue Webpush::Unauthorized, Webpush::ExpiredSubscription
20+
rescue WebPush::Unauthorized, WebPush::ExpiredSubscription
2121
s.destroy
2222
end
2323
end

0 commit comments

Comments
 (0)