mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-22 21:06:22 +00:00
Merge branch 'issue-15109-1' of https://0xacab.org/sutty/sutty into production.panel.sutty.nl
This commit is contained in:
commit
aec4280734
1 changed files with 19 additions and 4 deletions
|
@ -3,15 +3,16 @@
|
|||
class ActivityPub
|
||||
# Procesar las actividades a medida que llegan
|
||||
class ProcessJob < ApplicationJob
|
||||
attr_reader :body
|
||||
attr_reader :body, :initial_state
|
||||
|
||||
# Procesa la actividad en segundo plano
|
||||
#
|
||||
# @param :body [String]
|
||||
# @param :initial_state [Symbol,String]
|
||||
def perform(site:, body:, initial_state: :paused)
|
||||
@body = body
|
||||
@site = site
|
||||
@body = body
|
||||
@initial_state = initial_state
|
||||
|
||||
ActiveRecord::Base.connection_pool.with_connection do
|
||||
::ActivityPub.transaction do
|
||||
|
@ -25,10 +26,24 @@ class ActivityPub
|
|||
activity.update_activity_pub_state!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Al generar una excepción, en lugar de seguir intentando, enviamos
|
||||
# el reporte.
|
||||
rescue Exception => e
|
||||
ExceptionNotifier.notify_exception(e, 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.' })
|
||||
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
|
||||
end
|
||||
|
||||
private
|
||||
|
|
Loading…
Reference in a new issue