2017-06-26 07:51:32 +10:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-09-27 11:08:19 +10:00
|
|
|
class Vacuum::AccessTokensVacuum
|
|
|
|
def perform
|
|
|
|
vacuum_revoked_access_tokens!
|
|
|
|
vacuum_revoked_access_grants!
|
|
|
|
end
|
2017-06-26 07:51:32 +10:00
|
|
|
|
2022-09-27 11:08:19 +10:00
|
|
|
private
|
2018-08-19 23:48:29 +10:00
|
|
|
|
2022-09-27 11:08:19 +10:00
|
|
|
def vacuum_revoked_access_tokens!
|
2023-05-11 12:40:03 +10:00
|
|
|
Doorkeeper::AccessToken.where.not(expires_in: nil).where('created_at + make_interval(secs => expires_in) < NOW()').in_batches.delete_all
|
|
|
|
Doorkeeper::AccessToken.where.not(revoked_at: nil).where('revoked_at < NOW()').in_batches.delete_all
|
2022-09-27 11:08:19 +10:00
|
|
|
end
|
|
|
|
|
|
|
|
def vacuum_revoked_access_grants!
|
2023-05-11 12:40:03 +10:00
|
|
|
Doorkeeper::AccessGrant.where.not(expires_in: nil).where('created_at + make_interval(secs => expires_in) < NOW()').in_batches.delete_all
|
|
|
|
Doorkeeper::AccessGrant.where.not(revoked_at: nil).where('revoked_at < NOW()').in_batches.delete_all
|
2017-06-26 07:51:32 +10:00
|
|
|
end
|
|
|
|
end
|