mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-03-25 00:17:47 +01:00
19 lines
435 B
Ruby
19 lines
435 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Ajax::WebPushController < AjaxController
|
|
def key
|
|
certificate = Rpush::Webpush::App.find_by(name: "webpush").certificate
|
|
|
|
@response[:key] = JSON.parse(certificate)["public_key"]
|
|
end
|
|
|
|
def subscribe
|
|
WebPushSubscription.create!(
|
|
user: current_user,
|
|
subscription: params[:subscription]
|
|
)
|
|
|
|
@response[:status] = :okay
|
|
@response[:success] = true
|
|
end
|
|
end
|