2020-05-01 09:23:43 +00:00
|
|
|
class Api::V1::NotificationSubscriptionsController < Api::BaseController
|
|
|
|
before_action :set_user
|
|
|
|
|
|
|
|
def create
|
2020-05-05 18:40:56 +00:00
|
|
|
notification_subscription = NotificationSubscriptionBuilder.new(user: @user, params: notification_subscription_params).perform
|
|
|
|
|
2020-05-01 09:23:43 +00:00
|
|
|
render json: notification_subscription
|
|
|
|
end
|
|
|
|
|
2022-01-06 16:10:43 +00:00
|
|
|
def destroy
|
|
|
|
notification_subscription = NotificationSubscription.where(["subscription_attributes->>'push_token' = ?", params[:push_token]]).first
|
|
|
|
notification_subscription.destroy
|
|
|
|
head :ok
|
|
|
|
end
|
|
|
|
|
2020-05-01 09:23:43 +00:00
|
|
|
private
|
|
|
|
|
|
|
|
def set_user
|
|
|
|
@user = current_user
|
|
|
|
end
|
|
|
|
|
|
|
|
def notification_subscription_params
|
|
|
|
params.require(:notification_subscription).permit(:subscription_type, subscription_attributes: {})
|
|
|
|
end
|
|
|
|
end
|