* Create github repos request spec * Create article_mutes_spec.rb * Create moderation_service_spec.rb * Create push notification subscriptions spec * Add PodcastEpisodeDecorator specs * Remove randomness in test * Create specs for ArticleWithVideoCreationService * Update spec/decorators/podcast_episode_decorator_spec.rb Co-Authored-By: maestromac <krairit.siri@gmail.com>
19 lines
618 B
Ruby
19 lines
618 B
Ruby
class PushNotificationSubscriptionsController < ApplicationController
|
|
def create
|
|
@subscription = PushNotificationSubscription.where(endpoint: pns_params[:endpoint]).
|
|
first_or_create(
|
|
auth_key: pns_params[:keys][:auth],
|
|
p256dh_key: pns_params[:keys][:p256dh],
|
|
endpoint: pns_params[:endpoint],
|
|
user_id: current_user.id,
|
|
notification_type: "browser",
|
|
)
|
|
render json: { status: "success", endpoint: @subscription.endpoint }, status: 201
|
|
end
|
|
|
|
private
|
|
|
|
def pns_params
|
|
params.require(:subscription).permit({ keys: %i[auth p256dh] }, :endpoint)
|
|
end
|
|
end
|