5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-24 15:56:20 +00:00
panel/app/jobs/renew_distributed_press_tokens_job.rb

18 lines
646 B
Ruby
Raw Permalink Normal View History

# 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