19 lines
455 B
Ruby
19 lines
455 B
Ruby
# 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
|