mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 06:29:30 +08:00
30990006a9
This reduces chances of errors where consumers of strings mutate inputs and reduces memory usage of the app. Test suite passes now, but there may be some stuff left, so we will run a few sites on a branch prior to merging
24 lines
554 B
Ruby
24 lines
554 B
Ruby
# 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: [:p256dh, :auth])
|
|
end
|
|
end
|