5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-23 05:46:21 +00:00

fix: bloquear antes de empezar a modificar

closes #15791
This commit is contained in:
f 2024-03-22 13:09:13 -03:00
parent dad5f5f00c
commit 071f20762c
No known key found for this signature in database

View file

@ -64,9 +64,9 @@ class ActivityPub
# @return [ActivityPub::Object] # @return [ActivityPub::Object]
def object def object
@object ||= ::ActivityPub::Object.lock.find_or_initialize_by(uri: object_uri).tap do |o| @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.content = original_object if object_embedded?
o.lock! if o.persisted?
o.save! o.save!
# XXX: el objeto necesita ser guardado antes de poder # XXX: el objeto necesita ser guardado antes de poder
@ -94,9 +94,9 @@ class ActivityPub
.type_from(original_activity) .type_from(original_activity)
.lock .lock
.find_or_initialize_by(uri: original_activity[:id], activity_pub: activity_pub, actor: actor).tap do |a| .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 = original_activity.dup
a.content[:object] = object.uri a.content[:object] = object.uri
a.lock! if o.persisted?
a.save! a.save!
end end
end end
@ -107,6 +107,8 @@ class ActivityPub
# @return [Actor] # @return [Actor]
def actor def actor
@actor ||= ::ActivityPub::Actor.lock.find_or_initialize_by(uri: original_activity[:actor]).tap do |a| @actor ||= ::ActivityPub::Actor.lock.find_or_initialize_by(uri: original_activity[:actor]).tap do |a|
a.lock! if o.persisted?
unless a.instance unless a.instance
a.instance = ::ActivityPub::Instance.lock.find_or_create_by(hostname: URI.parse(a.uri).hostname) a.instance = ::ActivityPub::Instance.lock.find_or_create_by(hostname: URI.parse(a.uri).hostname)
@ -114,8 +116,6 @@ class ActivityPub
end end
site.instance_moderations.lock.find_or_create_by(instance: a.instance) site.instance_moderations.lock.find_or_create_by(instance: a.instance)
a.lock! if o.persisted?
a.save! a.save!
site.actor_moderations.lock.find_or_create_by(actor: a) site.actor_moderations.lock.find_or_create_by(actor: a)