lumi-api/app/controllers/webpush_subscriptions_controller.rb

27 lines
677 B
Ruby
Raw Normal View History

# frozen_string_literal: true
# Recibe suscripciones webpush
class WebpushSubscriptionsController < ApplicationController
before_action :authenticate!
def create
@subscription = current_pirata.webpush_subscriptions
.build(subscriptions_params)
if @subscription.save
render status: :created
else
# El único error que podemos tener es que la subscripción ya esté
# hecha, con lo que no hace falta que la volvamos a crear.
render status: :no_content
end
end
private
def subscriptions_params
params.require(:webpush_subscription)
.permit(:endpoint, :auth, :p256dh)
end
end