Update push subscription writing role
This commit is contained in:
parent
09ba5c9be8
commit
0d5acfc3fb
|
@ -52,12 +52,14 @@ class Web::PushSubscription < ApplicationRecord
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def unsubscribe_for(application_id, resource_owner)
|
def unsubscribe_for(application_id, resource_owner)
|
||||||
|
ActiveRecord::Base.connected_to(role: :writing) do
|
||||||
access_token_ids = Doorkeeper::AccessToken.where(application_id: application_id, resource_owner_id: resource_owner.id, revoked_at: nil)
|
access_token_ids = Doorkeeper::AccessToken.where(application_id: application_id, resource_owner_id: resource_owner.id, revoked_at: nil)
|
||||||
.pluck(:id)
|
.pluck(:id)
|
||||||
|
|
||||||
where(access_token_id: access_token_ids).delete_all
|
where(access_token_id: access_token_ids).delete_all
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
@ -89,6 +91,7 @@ class Web::PushSubscription < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_or_create_access_token
|
def find_or_create_access_token
|
||||||
|
ActiveRecord::Base.connected_to(role: :writing) do
|
||||||
Doorkeeper::AccessToken.find_or_create_for(
|
Doorkeeper::AccessToken.find_or_create_for(
|
||||||
Doorkeeper::Application.find_by(superapp: true),
|
Doorkeeper::Application.find_by(superapp: true),
|
||||||
session_activation.user_id,
|
session_activation.user_id,
|
||||||
|
@ -97,4 +100,5 @@ class Web::PushSubscription < ApplicationRecord
|
||||||
Doorkeeper.configuration.refresh_token_enabled?
|
Doorkeeper.configuration.refresh_token_enabled?
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue