5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-25 00:26:22 +00:00
panel/app/jobs/renew_distributed_press_tokens_job.rb
f 6e56778768
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
fix: renovar el token #13105
`touch` no corre `before_save`, con lo que el token nunca se renovaba
2023-04-15 11:16:58 -03:00

17 lines
646 B
Ruby

# frozen_string_literal: true
# Renueva los tokens de Distributed Press antes que se venzan,
# activando los callbacks que hacen que se refresque el token.
class RenewDistributedPressTokensJob < ApplicationJob
# Renueva todos los tokens a punto de vencer o informa el error sin
# detener la tarea si algo pasa.
def perform
DistributedPressPublisher.with_about_to_expire_tokens.find_each do |publisher|
publisher.save
rescue DistributedPress::V1::Error => e
data = { instance: publisher.instance, expires_at: publisher.client.token.expires_at }
ExceptionNotifier.notify_exception(e, data: data)
end
end
end