Revert "Upstream 20240517"

This commit is contained in:
KMY(雪あすか) 2024-05-24 08:15:12 +09:00 committed by GitHub
parent 9c006fd893
commit f6dec44e95
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2347 changed files with 26470 additions and 87494 deletions

View file

@ -16,8 +16,6 @@
#
class SessionActivation < ApplicationRecord
include BrowserDetection
belongs_to :user, inverse_of: :session_activations
belongs_to :access_token, class_name: 'Doorkeeper::AccessToken', dependent: :destroy, optional: true
belongs_to :web_push_subscription, class_name: 'Web::PushSubscription', dependent: :destroy, optional: true
@ -26,11 +24,24 @@ class SessionActivation < ApplicationRecord
to: :access_token,
allow_nil: true
def detection
@detection ||= Browser.new(user_agent)
end
def browser
detection.id
end
def platform
detection.platform.id
end
before_save :assign_user_agent
before_create :assign_access_token
class << self
def active?(id)
id && exists?(session_id: id)
id && where(session_id: id).exists?
end
def activate(**options)
@ -56,6 +67,10 @@ class SessionActivation < ApplicationRecord
private
def assign_user_agent
self.user_agent = '' if user_agent.nil?
end
def assign_access_token
self.access_token = Doorkeeper::AccessToken.create!(access_token_attributes)
end