From 071f20762c3ed2d435ed5351d5b9b5cd937865e5 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 22 Mar 2024 13:09:13 -0300 Subject: [PATCH] fix: bloquear antes de empezar a modificar closes #15791 --- app/jobs/activity_pub/process_job.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/jobs/activity_pub/process_job.rb b/app/jobs/activity_pub/process_job.rb index 9b7c30fc..a79abf5d 100644 --- a/app/jobs/activity_pub/process_job.rb +++ b/app/jobs/activity_pub/process_job.rb @@ -64,9 +64,9 @@ class ActivityPub # @return [ActivityPub::Object] def object @object ||= ::ActivityPub::Object.lock.find_or_initialize_by(uri: object_uri).tap do |o| + o.lock! if o.persisted? o.content = original_object if object_embedded? - o.lock! if o.persisted? o.save! # XXX: el objeto necesita ser guardado antes de poder @@ -94,9 +94,9 @@ class ActivityPub .type_from(original_activity) .lock .find_or_initialize_by(uri: original_activity[:id], activity_pub: activity_pub, actor: actor).tap do |a| + a.lock! if o.persisted? a.content = original_activity.dup a.content[:object] = object.uri - a.lock! if o.persisted? a.save! end end @@ -107,6 +107,8 @@ class ActivityPub # @return [Actor] def actor @actor ||= ::ActivityPub::Actor.lock.find_or_initialize_by(uri: original_activity[:actor]).tap do |a| + a.lock! if o.persisted? + unless a.instance a.instance = ::ActivityPub::Instance.lock.find_or_create_by(hostname: URI.parse(a.uri).hostname) @@ -114,8 +116,6 @@ class ActivityPub end site.instance_moderations.lock.find_or_create_by(instance: a.instance) - - a.lock! if o.persisted? a.save! site.actor_moderations.lock.find_or_create_by(actor: a)