Further refactor

This commit is contained in:
Claire 2024-05-06 11:51:47 +02:00
parent 0a7de5d1ee
commit ab12a443a2
2 changed files with 4 additions and 2 deletions

View File

@ -43,11 +43,11 @@ class Api::V1::Push::SubscriptionsController < Api::BaseController
private
def destroy_web_push_subscriptions!
Web::PushSubscription.where(access_token_id: doorkeeper_token.id).destroy_all
doorkeeper_token.web_push_subscriptions.destroy_all
end
def set_push_subscription
@push_subscription = Web::PushSubscription.find_by(access_token_id: doorkeeper_token.id)
@push_subscription = doorkeeper_token.web_push_subscriptions.first
end
def check_push_subscription

View File

@ -6,6 +6,8 @@ module AccessTokenExtension
included do
include Redisable
has_many :web_push_subscriptions, class_name: 'Web::PushSubscription', inverse_of: :access_token
after_commit :push_to_streaming_api
end