mirror of
https://0xacab.org/sutty/sutty
synced 2025-03-17 04:38:21 +00:00
Merge branch 'issue-15109-1' into production.panel.sutty.nl
This commit is contained in:
commit
9079b670a0
2 changed files with 11 additions and 42 deletions
|
@ -19,25 +19,16 @@ class ActivityPub
|
||||||
#
|
#
|
||||||
# @param error [Exception]
|
# @param error [Exception]
|
||||||
# @return [Bool]
|
# @return [Bool]
|
||||||
def handle_error(error)
|
discard_on(FastJsonparser::ParseError) do |error|
|
||||||
case error
|
|
||||||
when FastJsonparser::ParseError
|
|
||||||
expire
|
|
||||||
|
|
||||||
ExceptionNotifier.notify_exception(error, data: { site: site.name, object: object.uri, body: response.body })
|
ExceptionNotifier.notify_exception(error, data: { site: site.name, object: object.uri, body: response.body })
|
||||||
|
|
||||||
false
|
|
||||||
when ActiveRecord::RecordInvalid, SocketError, SystemCallError, Net::OpenTimeout, OpenSSL::OpenSSLError
|
|
||||||
retry_in(ApplicationJob.random_wait)
|
|
||||||
|
|
||||||
false
|
|
||||||
else
|
|
||||||
expire
|
|
||||||
|
|
||||||
true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
retry_on ActiveRecord::RecordInvalid
|
||||||
|
retry_on SocketError, wait: ApplicationJob.random_wait
|
||||||
|
retry_on SystemCallError, wait: ApplicationJob.random_wait
|
||||||
|
retry_on Net::OpenTimeout, wait: ApplicationJob.random_wait
|
||||||
|
retry_on OpenSSL::OpenSSLError, wait: ApplicationJob.random_wait
|
||||||
|
|
||||||
def perform(site:, object_id:)
|
def perform(site:, object_id:)
|
||||||
ActivityPub::Object.transaction do
|
ActivityPub::Object.transaction do
|
||||||
@site = site
|
@site = site
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
class ActivityPub
|
class ActivityPub
|
||||||
# Procesar las actividades a medida que llegan
|
# Procesar las actividades a medida que llegan
|
||||||
class ProcessJob < ApplicationJob
|
class ProcessJob < ApplicationJob
|
||||||
attr_reader :body, :initial_state
|
attr_reader :body
|
||||||
|
|
||||||
|
retry_on ActivityPub::RecordInvalid
|
||||||
|
|
||||||
# Procesa la actividad en segundo plano
|
# Procesa la actividad en segundo plano
|
||||||
#
|
#
|
||||||
|
@ -12,7 +14,6 @@ class ActivityPub
|
||||||
def perform(site:, body:, initial_state: :paused)
|
def perform(site:, body:, initial_state: :paused)
|
||||||
@site = site
|
@site = site
|
||||||
@body = body
|
@body = body
|
||||||
@initial_state = initial_state
|
|
||||||
|
|
||||||
ActiveRecord::Base.connection_pool.with_connection do
|
ActiveRecord::Base.connection_pool.with_connection do
|
||||||
::ActivityPub.transaction do
|
::ActivityPub.transaction do
|
||||||
|
@ -28,29 +29,6 @@ class ActivityPub
|
||||||
end
|
end
|
||||||
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
|
private
|
||||||
|
|
||||||
# Si el objeto ya viene incorporado en la actividad o lo tenemos
|
# Si el objeto ya viene incorporado en la actividad o lo tenemos
|
||||||
|
|
Loading…
Reference in a new issue