mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-22 06:06:45 +00:00
Add access_tokens
association for User
This commit is contained in:
parent
2fa4c24575
commit
8ad93f9923
|
@ -89,6 +89,7 @@ class User < ApplicationRecord
|
||||||
accepts_nested_attributes_for :account
|
accepts_nested_attributes_for :account
|
||||||
|
|
||||||
has_many :applications, class_name: 'Doorkeeper::Application', as: :owner, dependent: nil
|
has_many :applications, class_name: 'Doorkeeper::Application', as: :owner, dependent: nil
|
||||||
|
has_many :access_tokens, class_name: 'Doorkeeper::AccessToken', foreign_key: :resource_owner_id, dependent: nil, inverse_of: false
|
||||||
has_many :backups, inverse_of: :user, dependent: nil
|
has_many :backups, inverse_of: :user, dependent: nil
|
||||||
has_many :invites, inverse_of: :user, dependent: nil
|
has_many :invites, inverse_of: :user, dependent: nil
|
||||||
has_many :markers, inverse_of: :user, dependent: :destroy
|
has_many :markers, inverse_of: :user, dependent: :destroy
|
||||||
|
@ -281,8 +282,7 @@ class User < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def applications_last_used
|
def applications_last_used
|
||||||
Doorkeeper::AccessToken
|
access_tokens
|
||||||
.where(resource_owner_id: id)
|
|
||||||
.used
|
.used
|
||||||
.group(:application_id)
|
.group(:application_id)
|
||||||
.maximum(:last_used_at)
|
.maximum(:last_used_at)
|
||||||
|
|
Loading…
Reference in a new issue