5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2025-03-16 20:18:18 +00:00

Merge branch 'issue-15109-1' into production.panel.sutty.nl

This commit is contained in:
f 2024-03-28 10:14:18 -03:00
commit 9079b670a0
No known key found for this signature in database
2 changed files with 11 additions and 42 deletions

View file

@ -19,25 +19,16 @@ class ActivityPub
#
# @param error [Exception]
# @return [Bool]
def handle_error(error)
case error
when FastJsonparser::ParseError
expire
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
discard_on(FastJsonparser::ParseError) do |error|
ExceptionNotifier.notify_exception(error, data: { site: site.name, object: object.uri, body: response.body })
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:)
ActivityPub::Object.transaction do
@site = site

View file

@ -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