mirror of https://github.com/tootsuite/mastodon
Add `used` scope to access token
parent
44d92fa4f6
commit
2fa4c24575
|
@ -13,6 +13,7 @@ module AccessTokenExtension
|
|||
scope :expired, -> { where.not(expires_in: nil).where('created_at + MAKE_INTERVAL(secs => expires_in) < NOW()') }
|
||||
scope :not_revoked, -> { where(revoked_at: nil) }
|
||||
scope :revoked, -> { where.not(revoked_at: nil).where(revoked_at: ...Time.now.utc) }
|
||||
scope :used, -> { where.not(last_used_at: nil) }
|
||||
end
|
||||
|
||||
def revoke(clock = Time)
|
||||
|
|
|
@ -283,7 +283,7 @@ class User < ApplicationRecord
|
|||
def applications_last_used
|
||||
Doorkeeper::AccessToken
|
||||
.where(resource_owner_id: id)
|
||||
.where.not(last_used_at: nil)
|
||||
.used
|
||||
.group(:application_id)
|
||||
.maximum(:last_used_at)
|
||||
.to_h
|
||||
|
|
Loading…
Reference in New Issue