mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-01-18 14:16:00 +01:00
Create migration for adding an rpush app for webpush
This commit is contained in:
parent
92ba2d7c9b
commit
4e08f035d1
1 changed files with 18 additions and 0 deletions
18
db/migrate/20220909220449_add_webpush_app.rb
Normal file
18
db/migrate/20220909220449_add_webpush_app.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "webpush"
|
||||
|
||||
class AddWebpushApp < ActiveRecord::Migration[6.1]
|
||||
def up
|
||||
vapid_keypair = Webpush.generate_key.to_hash
|
||||
app = Rpush::Webpush::App.new
|
||||
app.name = "webpush"
|
||||
app.certificate = vapid_keypair.merge(subject: "user@example.com").to_json # TODO: put an email address here
|
||||
app.connections = 1
|
||||
app.save!
|
||||
end
|
||||
|
||||
def down
|
||||
Rpush::Webpush::App.find_by(name: "webpush").destroy!
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue