5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-26 16:26:21 +00:00

Merge branch 'issue-15109-1' of https://0xacab.org/sutty/sutty into production.panel.sutty.nl

This commit is contained in:
Sutty 2024-03-22 16:09:41 +00:00
commit 24659b374f

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)