From 97653d98b6d3f0d2d667eb153f5e70e8b9b272d1 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 13 Mar 2024 17:02:01 -0300 Subject: [PATCH] fix: prevenir deadlocks closes #15555 closes #15556 closes #15557 closes #15558 closes #15559 closes #15560 --- app/models/activity_pub/activity/delete.rb | 26 ++++++++++++---------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/app/models/activity_pub/activity/delete.rb b/app/models/activity_pub/activity/delete.rb index 6a23a8b5..1fbe5691 100644 --- a/app/models/activity_pub/activity/delete.rb +++ b/app/models/activity_pub/activity/delete.rb @@ -13,22 +13,24 @@ class ActivityPub # lo haría la Social Inbox por nosotres. # @see {https://docs.joinmastodon.org/spec/security/#ld} def update_activity_pub_state! - ActivityPub.transaction do - object = ActivityPub::Object.find_by(uri: ActivityPub.uri_from_object(content['object'])) + ActiveRecord::Base.connection_pool.with_connection do + ActivityPub.transaction do + object = ActivityPub::Object.find_by(uri: ActivityPub.uri_from_object(content['object'])) - if object.present? - object.activity_pubs.find_each do |activity_pub| - activity_pub.remove! if activity_pub.may_remove? + if object.present? + object.activity_pubs.find_each do |activity_pub| + activity_pub.remove! if activity_pub.may_remove? + end + + # Encontrar todas las acciones de moderación de le actore + # eliminade y moverlas a eliminar. + if object.actor_type? && object.actor.present? + ActorModeration.where(actor_id: object.actor.id).remove_all! + end end - # Encontrar todas las acciones de moderación de le actore - # eliminade y moverlas a eliminar. - if object.actor_type? && object.actor.present? - ActorModeration.where(actor_id: object.actor.id).remove_all! - end + activity_pub.remove! if activity_pub.may_remove? end - - activity_pub.remove! if activity_pub.may_remove? end end end