mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-26 14:06:21 +00:00
fix: activejob usa su propio método
closes #15621 closes #15622 closes #15623 closes #15729 closes #15730 closes #15731 closes #15735 closes #15736 closes #15824 closes #15838 closes #15839 closes #15882
This commit is contained in:
parent
142962160a
commit
ca4017dbd0
1 changed files with 3 additions and 25 deletions
|
@ -3,7 +3,9 @@
|
|||
class ActivityPub
|
||||
# Procesar las actividades a medida que llegan
|
||||
class ProcessJob < ApplicationJob
|
||||
attr_reader :body, :initial_state
|
||||
attr_reader :body
|
||||
|
||||
retry_on ActivityPub::RecordInvalid
|
||||
|
||||
# Procesa la actividad en segundo plano
|
||||
#
|
||||
|
@ -12,7 +14,6 @@ class ActivityPub
|
|||
def perform(site:, body:, initial_state: :paused)
|
||||
@site = site
|
||||
@body = body
|
||||
@initial_state = initial_state
|
||||
|
||||
ActiveRecord::Base.connection_pool.with_connection do
|
||||
::ActivityPub.transaction do
|
||||
|
@ -28,29 +29,6 @@ class ActivityPub
|
|||
end
|
||||
end
|
||||
|
||||
# Al generar una excepción, en lugar de seguir intentando, enviamos
|
||||
# el reporte.
|
||||
#
|
||||
# @param error [Exception]
|
||||
# @return [Bool]
|
||||
def handle_error(error)
|
||||
case error
|
||||
when ActiveRecord::RecordInvalid then retry_in(ApplicationJob.random_wait)
|
||||
else
|
||||
ExceptionNotifier.notify_exception(
|
||||
error,
|
||||
data: {
|
||||
site: site.name,
|
||||
body: body,
|
||||
initial_state: initial_state,
|
||||
activity: original_activity,
|
||||
message: 'Esta acción se canceló automáticamente, para regenerarla, volver a correr el proceso con los mismos parámetros.'
|
||||
})
|
||||
end
|
||||
|
||||
false
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Si el objeto ya viene incorporado en la actividad o lo tenemos
|
||||
|
|
Loading…
Reference in a new issue