discourse/app/controllers/push_notification_controller.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

24 lines
553 B
Ruby
Raw Permalink Normal View History

# frozen_string_literal: true
class PushNotificationController < ApplicationController
layout false
before_action :ensure_logged_in
skip_before_action :preload_json
def subscribe
PushNotificationPusher.subscribe(current_user, push_params, params[:send_confirmation])
render json: success_json
end
def unsubscribe
PushNotificationPusher.unsubscribe(current_user, push_params)
render json: success_json
end
private
def push_params
params.require(:subscription).permit(:endpoint, keys: %i[p256dh auth])
end
end