mirror of
https://github.com/Retrospring/retrospring.git
synced 2024-11-20 14:19:53 +01:00
18 lines
437 B
Ruby
18 lines
437 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "web-push"
|
|
|
|
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: APP_CONFIG.fetch("contact_email")).to_json
|
|
app.connections = 1
|
|
app.save!
|
|
end
|
|
|
|
def down
|
|
Rpush::Webpush::App.find_by(name: "webpush").destroy!
|
|
end
|
|
end
|